Not able to get CheckedItems for multiselect radcombobox when binding data from dynamically at codebehind.

2 posts, 0 answers
  1. Megha
    Megha avatar
    3 posts
    Member since:
    Apr 2014

    Posted 25 Apr 2014 Link to this post

    Hi I am using a multiselect radcombobox where i am binding the data dynamically at code behind. There is a rad button too on the page. On button click event I am always getting the CheckedItems.count = 0 at code behind. However if I am adding items in radcombo at UI side, I am able to get CheckedItems.count. Please suggest is there any way to get CheckedItems.count when data is binding dynamically at code behind. 
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Apr 2014 in reply to Megha Link to this post

    Hi Megha,

    Please try the following sample code snippet to get the count of the checked items of a dynamically bind RadComboBox.

    ASPX:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" CheckBoxes="true">
    </telerik:RadComboBox>
    <telerik:RadButton ID="radbtnCheckedItem" runat="server" Text="Checked Item Count"
        OnClick="radbtnCheckedItem_Click">
    </telerik:RadButton>

    C#:
    public class ArrayListItems
    {
        private string itemName;
        public ArrayListItems(string item)
        {
            ItemName = item;
        }
        public string ItemName
        {
            get { return itemName; }
            set { itemName = value; }
        }
    }
    private ArrayList theCart()
    {
        ArrayList list = new ArrayList();
        list.Add(new ArrayListItems("Diamond"));
        list.Add(new ArrayListItems("Ruby"));
        list.Add(new ArrayListItems("Sapphire"));
        return list;
    }
    protected void Page_init(object sender, EventArgs e)
    {
        ArrayList list = theCart();
        RadComboBox1.DataSource = list;
        RadComboBox1.DataTextField = "ItemName";
        RadComboBox1.DataBind();
    }
     
    protected void radbtnCheckedItem_Click(object sender, EventArgs e)
    {
        int checkedItem = RadComboBox1.CheckedItems.Count;
        //your code
    }

    Please provide your full code if it doesn't help.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top