Access checked items in C#

7 posts, 0 answers
  1. Dona
    Dona avatar
    23 posts
    Member since:
    Apr 2013

    Posted 17 Jul 2013 Link to this post

    Hi

    There is a radcombobox with checkboxes enabled and how can I access all the checked items in C# code?

    Thanks all
    Dona.

  2. A2H
    A2H avatar
    177 posts
    Member since:
    Mar 2010

    Posted 17 Jul 2013 Link to this post

    Hello,

    You can use the RadCombobox's "CheckedItems" propertie to get all items which are checked.

    Ex:
    var collection = comboBox.CheckedItems;

    Please refer the link which will give you complete details.

    Thanks,
    A2H

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dona
    Dona avatar
    23 posts
    Member since:
    Apr 2013

    Posted 18 Jul 2013 Link to this post

    Not working. I am getting Count=3 on debugging. I want to access all those values of items.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Jul 2013 Link to this post

    Hi Dona,

    Please try the following C# code.

    C#:
    foreach (RadComboBoxItem checkeditem in RadComboBox1.CheckedItems)
    {
        string _value = checkeditem.Value; //looping through each checked item and accessing its value.
    }

    Thanks,
    Princy.
  6. Rajeeve
    Rajeeve avatar
    3 posts
    Member since:
    Aug 2016

    Posted 11 Aug Link to this post

    to get the checked combobox values in telerik (using javascript)

    var checkeditems;

    var combo = $find("<%= telerikcomboboxname.ClientID%>")

     var items = combo.get_checkedItems();

      for (i = 0; i < items.length; i++) {

                            if (i == 0) {
                                radvalue = Number(parseInt(items[i]._properties._data.value));
                               checkeditems=checkeditems+radvalue ;
                            }
                            else {
                                radvalue = Number(parseInt(items[i]._properties._data.value));
                                checkeditems= checkeditems+ "," + radvalue;
                            }

                   }
                        alert(Expenseitems);

     

    this will work 

    thanks all

  7. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    290 posts

    Posted 16 Aug Link to this post

    Hi Rajeeve,

    Thank you for the suggested solution.

    Note that this topic is on accessing checked items in the code-behind (C# / VB), while your suggestion is a client-side solution.

    Note also that you won't need to use private properties (_properties and _data) of the RadComboBoxItem object to access the values of the item. You could freely use instead the get_value() method from the exposed client-side API of the object.

    Moreover, if you do not initially set an empty string as a value of the checkeditems variable, it will produce the final result to have an "undefined" as prefix. In your suggestion, you also alert the wrong variable (Expenseitems), while the values are held in the checkeditems.

    Modified working version of your sample code would be:
    var checkeditems = '';
    var radvalue;
    var combo = $find("<%= RadComboBox1.ClientID%>")
    var items = combo.get_checkedItems();
    for (i = 0; i < items.length; i++) {
        radvalue = items[i].get_value();
        if (i == 0) {
            checkeditems = checkeditems + radvalue;
        }
        else {
            checkeditems = checkeditems + "," + radvalue;
        }
    }
    alert(checkeditems);

    Regards,
    Veselin Tsvetanov
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  8. Rajeeve
    Rajeeve avatar
    3 posts
    Member since:
    Aug 2016

    Posted 16 Aug in reply to Veselin Tsvetanov Link to this post

    yaaa you are right
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017