|
-
Jan 8th, 2010, 06:11 AM
#1
Thread Starter
Fanatic Member
check listbox
I am populating a check list box from the database as follows:
for (int i = 0; i < intClassID; i++)
{
strClassID = dtClass.Rows[i]["ClassID"].ToString();
strName = dtClass.Rows[i]["Name"].ToString();
chklstClass.Items.Add(new ListItem(strName, strClassID));
}
So each item in the listbox has an ID
Now I would like to retrieve so that the IDs are selected approprioately. This is what I do:
for (int i = 0; i <= dtClass.Rows.Count - 1; i++)
{
int intClassID = int.Parse(dtClass.Rows[i][0].ToString());
chklstClass.Items[intClassID].Selected = true;
}
It does not seem to get the proper ID's
What am I doing wrong?
is this to do with SetItemChecked(i, true) ?
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|