Read From Db Values And Bind CheckBox List

Jayakumars
Posted by Jayakumars under ASP.NET AJAX category on | Points: 40 | Views : 710
Read From Db Values And Bind CheckBox List
=========================================
sqlcmd = new SqlCommand("Select * from Table_1", sqlcon);
sqlcmd.CommandType = CommandType.Text ;
sqlcon.Open();
da = new SqlDataAdapter(sqlcmd);
da.Fill(dt);

for (int i = 0; i <= dt.Rows.Count; i++)
{
CheckBoxList chk1 = new CheckBoxList();
chk1.Items.Add(dt.DefaultView[0][i].ToString());
if (dt.DefaultView[0][i].ToString() == "1")
{
chk1.Items[0].Selected = true;
}
form1.Controls.Add(chk1);
}

Comments or Responses

Login to post response