I have two checkedlistbox controls
1. chklst_type
2.chklst_test
chklst_type I fill through database.
On Checking of an item from chklst_type, I fill second checkedlistbox control i.e.(chklst_test)
I want to uncheck the last checked item from chklst_type and also clear the related items from the second checkedlistbox control (chklst_test).
I want to toggle it.
Means at a time only one checkbox should be checked from first control and its related items are shown in the second control.
Here is my code...
private void chklst_type_ItemCheck(object sender, ItemCheckEventArgs e)
{
try
{
int j;
for (j = 0; j <= (chklst_type.Items.Count - 1); j++)
{
if (chklst_type.GetItemCheckState(j)==CheckState.Unchecked)
<pre>
{
id = Convert.ToInt32(chklst_type.SelectedIndex);
id = id + 1;
sqlQry = "select Lab_Test from LabTest where Type_Id='" + id + "'";
adapter = new SqlDataAdapter(sqlQry, Connection.sqlconn);
ds = new DataSet();
adapter.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
chklst_test.Items.Add(ds.Tables[0].Rows[i]["Lab_Test"].ToString());
}
}
}
}
catch (Exception ex)
{
Connection.m_MessageLog.Log("frmRecLabTest.cs", 57, 02636, 'U', 'E', 0, "chklst_type_ItemCheck:" + ex.ToString());
}
}