Note that there are some explanatory texts on larger screens.

plurals
  1. POcheckboxlist issue
    primarykey
    data
    text
    <p>I have 5 <code>CheckBoxList</code> controls with <code>ID</code>'s of <code>CheckBoxList1</code>,<code>CheckBoxList2</code>, and so on. They have same list items within them. </p> <p>Now when I write the following line:</p> <pre><code>CheckBoxList1.Items[0].Selected = true; </code></pre> <p>It selects the 1st item of <code>CheckBoxList1</code> but the 1st item of all the other <code>CheckBoxList</code>'s gets selected as well. Any idea why is such a mysterious thing happening?</p> <p>All the <code>CheckBoxList</code>'s have the same number of items, with each item having the same text and the same value.</p> <p>They are populated dynamically with data being fetched from the database.</p> <pre><code>SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM EMPLOYEE_TABLE WHERE EMPLOYEE_TABLE.EmployeeID NOT IN (SELECT ORG_UNIT.ManagerID FROM ORG_UNIT WHERE ORG_UNIT.OrgUnitID = '" + teamid + "') AND EMPLOYEE_TABLE.OrgUnitID = '" + teamid + "'",con); DataSet da = new DataSet(); DataTable table = new DataTable(); adapter.Fill(table); adapter.Fill(da); int count = da.Tables[0].Rows.Count; CheckBoxList1.Items.Clear(); CheckBoxList2.Items.Clear(); CheckBoxList3.Items.Clear(); CheckBoxList4.Items.Clear(); CheckBoxList5.Items.Clear(); no_of_listitem = count; for (int i = 0; i &lt; table.Rows.Count; i++) { ListItem temp = new ListItem(); temp.Text = table.Rows[i]["FName"].ToString(); employeeid[i] = table.Rows[i]["EmployeeID"].ToString(); temp.Value = i.ToString(); CheckBoxList1.Items.Add(temp); CheckBoxList2.Items.Add(temp); CheckBoxList3.Items.Add(temp); CheckBoxList4.Items.Add(temp); CheckBoxList5.Items.Add(temp); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload