Click here to Skip to main content
15,124,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to fetch data from datagridview to checkedlistbox while updating in windows form in C#.

Data will be already stored in database (like:- A, B, C, D, )during insert operation, while updating i need to fetch the data from database to checkedlistbox, and the data should be checked.

Data from database will be split and should compare with data in checkedlistbox, if both database item and checklistbox items equal then the item in checkedlistbox should be checked.

What I have tried:

string category = dgEntry.CurrentRow.Cells[8].Value.ToString();
string[] strCat = category.Split(',');
int length = strCat.Length;
for (int i = 0; i < length ; i++)
{
    string fetch = strCat[i];
    foreach (object item in clbEntry_IndividualItems.Items)
    {
        DataRowView row = item as DataRowView;
        if (row[0].ToString() == strCat[i].ToString())
        {
            clbEntry_IndividualItems.SetItemChecked(i, true);
        }
    }
}


I a beginner in c#, Please help to solve this problem
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900