Checkboxlist - set checked status from database
Posted on 2006-11-07
I have a checkboxlist bound to an object data source in a VB ASP.NET 2.0 environment.
My object datasource returns a three column sqlDataReader with the following columns: "TagName", "TagID", "Selected". The "Selected" column is boolean. I set the "DataTextField" = "TagName" and the "DataValueField" = "TagID". Unfortunately there is no "DataCheckedField" property to set the selected status of the check box to the value from the "Selected" column.
When I load the checkboxlist I want the items for which the "Selected" field from the database equals "True" to be selected in the checkboxlist. What is the easiest way to do this? If the answer involves setting it with code which it probably does, please use VB.
Note: I have no problem writing back the user's selections to the database.