ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Set CheckBoxList Item checked (selected) on GridView Edit Button Click using C# in ASP.Net<p>I found the answer and it is working</p> <p>Thanks</p> <pre class="brush: html">&lt;asp:CheckBoxList ID=&#34;CheckBoxList1&#34; runat=&#34;server&#34;&gt; &lt;asp:ListItem&gt;Card&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Cash&lt;/asp:ListItem&gt; &lt;/asp:CheckBoxList&gt;</pre> <p>&nbsp;</p> <pre class="brush: csharp"> private void UpdateFile(string path, string fileName) { List&lt;String&gt; open = new List&lt;String&gt;(); if (ddlTimeFrom.SelectedIndex &gt; 0 &amp;&amp; ddlTimeTo.SelectedIndex &gt; 0) { open.Add(ddlTimeFrom.Text); open.Add(ddlTimeTo.Text); } string open2 = string.Join(&#34;, &#34;, open); string constr = ConfigurationManager.ConnectionStrings[&#34;Q_SS_regnConnectionString1&#34;].ConnectionString; SqlConnection con = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(&#34;UPDATE SP_Afterlogin2 SET Images =@Path,Bussiness_name=@Bussiness_name,city=@city,Image_name=@Image_name,name=@name,toll_free=@toll_free,website_link=@website_link,payment_mode=@payment_mode,email=@email,address=@address,h_open=@h_open WHERE Id =@Id&#34;, con); cmd.Parameters.AddWithValue(&#34;@Id&#34;, Id.Value); cmd.Parameters.AddWithValue(&#34;@Path&#34;, path); cmd.Parameters.AddWithValue(&#34;@Bussiness_name&#34;, DropDownList1.SelectedValue.ToString()); cmd.Parameters.AddWithValue(&#34;@city&#34;, DropDownList2.SelectedValue.ToString()); cmd.Parameters.AddWithValue(&#34;@name&#34;, txt_name.Text); cmd.Parameters.AddWithValue(&#34;@toll_free&#34;, txt_toll.Text); cmd.Parameters.AddWithValue(&#34;@website_link&#34;, txt_link.Text); cmd.Parameters.AddWithValue(&#34;@payment_mode&#34;,CheckBoxList1.SelectedValue.ToString()); cmd.Parameters.AddWithValue(&#34;@email&#34;, txt_email.Text); cmd.Parameters.AddWithValue(&#34;@Image_name&#34;,fileName); cmd.Parameters.AddWithValue(&#34;@address&#34;, txt_Address.Text); cmd.Parameters.AddWithValue(&#34;@h_open&#34;, open2); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } protected void btnClear_Click(object sender, EventArgs e) { ClearControls(); } protected void btnEdit_Click(object sender, EventArgs e) { try { Button btn = sender as Button; GridViewRow grow = btn.NamingContainer as GridViewRow; Id.Value = (grow.FindControl(&#34;Id&#34;) as Label).Text; Image img = (grow.FindControl(&#34;img&#34;) as Image); txt_email.Text = (grow.FindControl(&#34;lblemail&#34;) as Label).Text; txt_link.Text = (grow.FindControl(&#34;lblweb&#34;) as Label).Text; txt_img.Text = (grow.FindControl(&#34;lblimg&#34;) as Label).Text; txt_name.Text = (grow.FindControl(&#34;lblname&#34;) as Label).Text; //CheckBoxList1.Text = (grow.FindControl(&#34;lblpay&#34;) as Label).Text; txt_toll.Text = (grow.FindControl(&#34;lbltoll&#34;) as Label).Text; txt_Address.Text = (grow.FindControl(&#34;lblAddress&#34;) as Label).Text; Image1.ImageUrl = img.ImageUrl; btnUpdate.Visible = true; string value = (grow.FindControl(&#34;lblBname&#34;) as Label).Text; DropDownList1.ClearSelection(); DropDownList1.Items.FindByText(value).Selected = true; string value2 = (grow.FindControl(&#34;lblcity&#34;) as Label).Text; DropDownList2.ClearSelection(); DropDownList2.Items.FindByValue(value2).Selected = true; string from = (grow.FindControl(&#34;lblopen&#34;) as Label).Text; string[] parts = from.Split(&#39;,&#39;); ddlTimeFrom.ClearSelection();ddlTimeTo.ClearSelection(); ddlTimeFrom.Items.FindByValue(parts[0].Trim()).Selected = true; ddlTimeTo.Items.FindByValue(parts[1].Trim()).Selected = true; string chk = (grow.FindControl(&#34;lblpay&#34;) as Label).Text; string[] sp = chk.Split(&#39;,&#39;); CheckBoxList1.ClearSelection(); CheckBoxList1.Items.FindByValue(sp[0].Trim()).Selected = true; CheckBoxList1.Items.FindByValue(sp[1].Trim()).Selected = true; } catch(Exception ex) { Response.Write(ex); } } </pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/839655/Set-CheckBoxList-Item-checked-selected-on-GridView-Edit-Button-Click-using-C-in-ASPNet/https://www.aspforums.net:443/Threads/839655/Set-CheckBoxList-Item-checked-selected-on-GridView-Edit-Button-Click-using-C-in-ASPNet/Tue, 30 Jul 2019 23:30:30 GMT