How to read Custom Attribute

4 posts, 1 answers
  1. Shakti SIngh Dulawat
    Shakti SIngh Dulawat avatar
    89 posts
    Member since:
    Oct 2009

    Posted 01 Aug 2012 Link to this post

    I am trying to make a multi colum combo box 
    RadComboBoxItem item = new RadComboBoxItem();
     
                    item.Text = selectionItem.ShortName.ToString();
                    item.Value = selectionItem.SelectionId.ToString();
     
                    item.Attributes.Add("SelectionNumber", selectionItem.SelectionNumber.ToString());
                    item.Attributes.Add("DrawnNumber", selectionItem.DrawnNumber.ToString());
     
                    radComboBoxSelection.Items.Add(item);
     
                    item.DataBind();



    But when trying to read value of radComboBoxSelection.SelectedItem.Attributes  I am getting error what are other way to read value of 

    DrawnNumber
     

    Thanks,


  2. Answer
    Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 02 Aug 2012 Link to this post

    Hello Shakti SIngh Dulawat,

    In order to access the value of a specific custom attribute, please consider using the following approach:

    string attr = radComboBoxSelection.SelectedItem.Attributes["DrawnNumber"];


    All the best,
    Nencho
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shakti SIngh Dulawat
    Shakti SIngh Dulawat avatar
    89 posts
    Member since:
    Oct 2009

    Posted 10 Aug 2012 Link to this post

    I use this method but it always show me NULL is there is any other property we have to set for rad combo box?

    Thanks,
    Shakti
  5. Shakti SIngh Dulawat
    Shakti SIngh Dulawat avatar
    89 posts
    Member since:
    Oct 2009

    Posted 13 Aug 2012 Link to this post

    Thanks the Problem is resolve using this!
    If you use LoadOnDemand with the RadComboBox you cannot access the SelectedItems and SelectedIndex on the server-side. For a further explanation of this you can read over this documentation article:

    http://www.telerik.com/help/aspnet-ajax/load-on-demand-access-items-server-side.html

    You can use the SelectedValue property I believe (the article mentions it as well) and perhaps that will help you in this scenario. 


    Thanks,
    Shakti
Back to Top