HI
I am facing problem in finding the checked items in checkbox list. Actually the list items for the checkbox list are loaded from database. But by using the code below i am not able to find the checked item in the list and the items are always returning false. Below is my code Can someone please help me with this?
Please be correct.i need to get return items which is checked in check box list from in c#
Class1.connect();
SqlDataAdapter sda4 = new SqlDataAdapter("prcchklisttestupdate", Class1.con);
sda4.SelectCommand.CommandType = CommandType.StoredProcedure;
sda4.SelectCommand.Parameters.AddWithValue("@ibookingid", SqlDbType.Int).Value = label6.Text;
DataTable dt4 = new DataTable();
sda4.Fill(dt4);
for (int i2 = 0; i2 < dt4.Rows.Count; i2++)
{
foreach (string item in chkList1.Items)
{
if (item == dt4.Rows[i2][0].ToString())
{
chkList1.SelectedValue = true;
}
}
}
Loading
arun prasathPosted Oct 6, 2014, 6:40 AM
make it as below and try.
for (int i2 = 0; i2 < dt4.Rows.Count; i2++)
{
foreach (ListItem item in chkList1.Items)
{
if (item.Text == dt4.Rows[i2][0].ToString())
{
item.Checked= true;
}
}
}
u will get the item list using checkbox items as follow
list