In C#, I am trying to Check an item in a CheckBoxList where the text equals what I require.
I would modify the code to check items that exist in the database.
<
I tried adding dynamically created ListItem and assigning the selected value.
foreach(var item in yourListFromDB)
{
ListItem listItem = new ListItem();
listItem.Text = item.name;
listItem.Value = Convert.ToString(item.value);
listItem.Selected=item.isSelected;
checkedListBox1.Items.Add(listItem);
}
checkedListBox1.DataBind();
avoid using binding the DataSource as it will not bind the checked/unchecked from DB.