This is a migrated thread and some comments may be shown as answers.

How to read Custom Attribute

3 Answers 428 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Shakti SIngh Dulawat
Top achievements
Rank 1
Shakti SIngh Dulawat asked on 01 Aug 2012, 06:16 PM
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,


3 Answers, 1 is accepted

Sort by
0
Accepted
Nencho
Telerik team
answered on 02 Aug 2012, 03:20 PM
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.
0
Shakti SIngh Dulawat
Top achievements
Rank 1
answered on 10 Aug 2012, 06:59 PM
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
0
Shakti SIngh Dulawat
Top achievements
Rank 1
answered on 13 Aug 2012, 05:43 PM
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
Tags
ComboBox
Asked by
Shakti SIngh Dulawat
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Shakti SIngh Dulawat
Top achievements
Rank 1
Share this question
or