How to get checkboxlist item value

This is how I am adding values and text to my checkboxlist in c#

private void populateFruitList() {
    string selectCommand = "SELECT FruitName, FruitID FROM Fruit_Crate";

    using (SqlDataSource ds = new SqlDataSource(ConnectionString(), selectCommand)) {
        CheckBoxList1.DataSource = ds;
        CheckBoxList1.DataTextField = "FruitName";
        CheckBoxList1.DataValueField = "FruitID";

This is how I am trying to get value but intellisence not helping,

foreach (CheckBox cb in CheckBoxList1.Items) {
        myList.Add(cb.Value); // SAYS wrong Syntax

Can someone direct me to right syntax please?



CheckBoxList does not contain CheckBox items (or shouldn't), it's a collection of ListItems. It should look like this: -

foreach (ListItem cb in CheckBoxList1.Items) 

Need Your Help

Perl script that extracts data from HTML table

html perl table html-parsing

I need a Perl script to parse a simple HTML table with 2 columns.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.