Venkatesh Pettem

Venkatesh Pettem

  • NA
  • 343
  • 9.6k

Gridview Contamination

May 21 2017 3:23 AM
how to get checkboxlist checked data in gridview when we click on edit usin sqldatabase
 
 
 
void check_bind()
{
string intersts = "";
SqlCommand cmd = new SqlCommand("Select hobbies from Task ", cn);
SqlDataReader dr;
cn.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
intersts = dr["hobbies"].ToString();
}
cn.Close();
string[] arr = intersts.Split(',');
foreach (ListItem item in this.CheckBoxList1.Items)
{
foreach (string s in arr)
{
if (item.Text == s)
{
CheckBoxList1.SelectedValue = item.Text;
item.Selected = true;
}
GridView1.DataBind();
}
}
}
 

Answers (2)