I'd like to list multiple records from a database as checkboxes. I'd use
record's "Name" column for checkbox Text. Ideally I'd like to assign a
'hidden' record's ID to checkbox so I don't need to go back to the database
to query for the ID when checkbox is clicked on.
This is similar to what can be done with DropDownList (i.e. text and value).
Is there a way to do that with checkboxes?
Thanks,
Dan
David R. Longnecker - 08 Apr 2008 17:00 GMT
If you have a list of controls, you can use the CheckBoxList control and
assign it just like a DropDownList:
CheckBoxList cbList = new CheckBoxList();
cbList.DataSource = GetProducts();
cbList.DataTextField = "ProductName";
cbList.DataValueField = "ProductID";
cbList.DataBind();
HTH.
-dl
--
David R. Longnecker
http://blog.tiredstudent.com
> I'd like to list multiple records from a database as checkboxes. I'd
> use
[quoted text clipped - 8 lines]
> Thanks,
> Dan