I'm only guessing here so you'll have to try it out yourself, but it would seem that the item.ToString()
1. gives you the name of one of the favorite newspapers and in all the checkboxes the name of the newspaper
would be in the property cb.Text.
This is all guesswork as we didn't see the code yet that initialized the asp:checkbox instances and neither the code that reads in all the newspapers. I still think that cb.Text probably does the trick.
protected void CheckBoxList1_DataBound(object sender, EventArgs e)
{
IEnumerable results = FavoritesDataSource.Select();
foreach (var item in results)
{
foreach (ListItem cb in CheckBoxList1.Items)
{
if (item.ToString() == cb.Text)
{
cb.Selected = true;
}
}
}
Footnotes:
1. If FavoritsDataSource.Select() returned a list of objects of a type you wrote yourself, chances are good the ToString() method will not return anything sensible at all but the class name of those objects.
End Footnotes
Best Regards,
Manfred