Binding Checkboxes in the list

3 posts, 1 answers
  1. Vassili King
    Vassili King avatar
    60 posts
    Member since:
    May 2010

    Posted 06 May 2010 Link to this post

    Hi,

    I'm using a RadListBox with CheckBoxes option turned on. I bind the listbox to a table in a DataSet based on an event. The DataSet contains name, id and a bit flag per record (i.e., each row in the datatable would look similar to this:  "1", "Joe", true). I set Text and Value using DataTextField and DataValueField respectively. However, I can't seem to find a way to bind the checkboxes. Any ideas?

    Thank you!
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 May 2010 Link to this post

    H Vassil,

    One suggestion would be accessing the DataItem in ItemDatBound event of the RadListBox and explicitly setting the Checked property. Here is an example.

    C#:

     
        protected void RadListBox1_ItemDataBound(object sender, Telerik.Web.UI.RadListBoxItemEventArgs e)  
        {  
            RadListBoxItem item = (RadListBoxItem)e.Item;  
            DataRowView row = (DataRowView)item.DataItem;  
            if(Convert.ToBoolean(row["Flag"]))  // Check for the value returned  
            {  
                item.Checked = true;  
            }  
        } 

    -Shinu.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vassili King
    Vassili King avatar
    60 posts
    Member since:
    May 2010

    Posted 07 May 2010 Link to this post

    Thanks!
    This worked just fine.
Back to Top