Set CheckBox checked (selected) on GridView Edit Button Click using C# and VB.Net in ASP.Net

Last Reply 11 months ago By pandeyism

Posted 11 months ago

I am trying to set checked value in two different checkbox first is card pay and another is cash pay sohow can I set values in bot of them as i had joined the value of both checkbox to store in a single field 

please suggest


<asp:CheckBox ID="Cashpay" Text="Cash" runat="server" CssClass="bg-info" />
<asp:CheckBox ID="Cardpay" Text="Card" runat="server" CssClass="bg-info" />
<asp:TemplateField HeaderText="Payment Mode">
        <asp:Label ID="lblpay" runat="server" Text='<%#Eval("payment_mode") %>'></asp:Label>


        protected void btnEdit_Click(object sender, EventArgs e)
                Button btn = sender as Button;
                GridViewRow grow = btn.NamingContainer as GridViewRow;
                Id.Value = (grow.FindControl("Id") as Label).Text;
                Image img = (grow.FindControl("img") as Image);
                txt_email.Text = (grow.FindControl("lblemail") as Label).Text;
                txt_link.Text = (grow.FindControl("lblweb") as Label).Text;
                txt_img.Text = (grow.FindControl("lblimg") as Label).Text;
                txt_name.Text = (grow.FindControl("lblname") as Label).Text;
                //CheckBoxList1.Text = (grow.FindControl("lblpay") as Label).Text;
                txt_toll.Text = (grow.FindControl("lbltoll") as Label).Text;
                txt_Address.Text = (grow.FindControl("lblAddress") as Label).Text;
                Image1.ImageUrl = img.ImageUrl;
                btnUpdate.Visible = true;
                string value = (grow.FindControl("lblBname") as Label).Text;
                DropDownList1.Items.FindByText(value).Selected = true;
                string value2 = (grow.FindControl("lblcity") as Label).Text;
                DropDownList2.Items.FindByValue(value2).Selected = true;
                string from = (grow.FindControl("lblopen") as Label).Text;
                string[] parts = from.Split(',');
                ddlTimeFrom.Items.FindByValue(parts[0].Trim()).Selected = true;
                ddlTimeTo.Items.FindByValue(parts[1].Trim()).Selected = true;

                string chk = (grow.FindControl("lblpay") as Label).Text;
                string[] sp = chk.Split(',');
            catch(Exception ex)


This question does not have replies that have been liked.