Binding Listviews Checkbox Checked value

2 posts, 1 answers
  1. Thomas
    Thomas avatar
    1 posts
    Member since:
    Sep 2008

    Posted 22 Mar 2011 Link to this post


    I have been racking my brain and I think that this is probably something silly that I am missing. I have to generate a list of employee "requirements" in the form of checkboxes. I am databinding them to a database with the following fields:

    OptionID (unique Identifier)
    Name (for the display of the checkbox)
    Checked (a bit)

    Am I misunderstanding the Listbox behavior in that I would like to display the text field on a checkbox, with a "value" behind it, and then databind whether or not the checkbox should be checked?

    Please also note that I can (and did) create a template field with a checkbox in it, but these checkboxes do not behave the way I would like them to when using the following code from the intro to listboxes:


    StringBuilder sb = new StringBuilder(); 
    IList<RadListBoxItem> collection =RadListBox1.CheckedItems; 
    foreach (RadListBoxItem item in collection) 
        sb.Append(item.Value +  "<br />"); 


    The checked box in the template is not counting towards the checked value of the list item.

    I am jsut trying to cut down on code, because if I wanted to cycle through each item and manually check if it should be checked, I could do that using a radiobutton list.

    I am using Visual Studio 2010 with radcontrols for ajax Q2 2010 NET40.


    Thomas Turner








  2. Answer
    Dimitar Terziev
    Dimitar Terziev avatar
    1268 posts

    Posted 25 Mar 2011 Link to this post

    Hello Thomas,

    I've prepared a sample page demonstrating how to get the checked values from a data bound listbox. In this example page there are two listboxes, one using the default CheckBox functionality, and one having templated CheckBox control in it.

    I hope this would help you out.

    All the best,
    Dimitar Terziev
    the Telerik team
Back to Top