please check the code snippet below:
//Binding the checkedlist box
this.chkLB.DataSource = ds.Tables[0]; this.chkLB.DisplayMember = "Name"; this.chkLB.ValueMember = "Code"; //based on your requirement.....you can set the value member and displaymember OR
foreach(DataRow drItem in ds.Tables[0].Rows) { //this.chkLB.Items.Add(drItem["Name"]); this.chkLB.Items.Add(drItem); }
Let me know.
Hello,
for (int i = 0; i < cbl.Items.Count; i++)
{
if (cbl.Items[i].Selected)
// Insert Item into Database
string itemName = cbl.Items[i].Text;
string itemID = cbl.Items[i].Value;
}
Hope this is helpful !
Thanks
foreach(DataRowView view in myCheckedList.CheckedItems) { string a=(view[myCheckedList.ValueMember].ToString()); }