Reputation: 3147
Please refer the uploaded image which got when I run my web application.
Now i want to edit the values which i select from gridview and fill given checkboklist control with only checked items which is in database.
For example when I click edit for the item whose id is 5, it has 2 values "Yellow" and "Brown", so now only that values in checkboxlist control should be checked.
Upvotes: 0
Views: 2769
Reputation: 1959
string colors = "Yellow,Brown";
string[] col = colors.Split(',');
foreach (ListItem lst in CheckBoxList1.Items)
{
for (int i = 0; i <= col.Length-1; i++)
{
if (lst.Text == col[i])
{
lst.Selected = true;
break;
}
}
}
Here string colors
is your string which holds the comma seperated values .
Upvotes: 1