Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to populate checkboxes in checkboxlist
Message
 
To
17/11/2002 14:17:45
Rex Mahel
Realm Software, Llc
Ohio, United States
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00723656
Message ID:
00723899
Views:
8
Hi Rex,

You need to cycle through each record and set the Selected property.
cbList.DataTextField="ProductName";
cbList.DataValueField="Discontinued"; // boolean database column
cbList.DataBind();
foreach (ListItem li in cbList.Items) {
   li.Selected = bool.Parse(li.Value); // will check/uncheck, depending on "Discontinued" value
}
>All,
>
>Is there a property on the CBL that handles this with the DataBind() or do I need to cycle through all the checkboxes and set the Selected property?
>
>In my example I have the DataSource, DataTextField and DataValueField properties set, but the checkboxes are not showing checked.
>
>TIA
>
>Rex
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Reply
Map
View

Click here to load this message in the networking platform