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

RadDropDownList Databinding

2 Answers 460 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Zain
Top achievements
Rank 1
Zain asked on 02 Feb 2012, 04:46 PM
I have a RadDropDownList that I have successfully bound to a List object by setting the DisplayMember and ValueMember of the RadDropDownList to the properties of my data list object, and by setting the DataSource of the RadDropDown to the list.
The above takes care of populating the choices in RadDropDown.

I want to know if its possible to also bind the SelectedValue to another property in my data class. And if changes in this Data property would reflect back in the SelectedValue of the RadDropDown with the implementation of the INotifyPropertyChanged event for the Data property.

2 Answers, 1 is accepted

Sort by
0
Zain
Top achievements
Rank 1
answered on 02 Feb 2012, 09:48 PM
Nevermind, I figured this out on my own.
After setting the datasource of the dropdown to a list, I can add a Databinding to the dropdown, and bind the "SelectedValue" property of the dropdown to the data object property.

List <ListElement> myList = new List <ListElement>() { 
                                                                                      new ListElement() { ListElementVal = 1, ListElementDisp = "One" }, 
                                                                                      new ListElement() { ListElementVal = 2, ListElementDisp = "Two" }
                                                                                    };

myDropDown.ValueMember =

 

"ListElementVal";

 

myDropDown.DisplayMember =

 

"ListElementDisp";

 

myDropDown.DataSource =

 

myList;
myDropDown.DataBindings.Add("SelectedValue", dataObjInst, "dataObjProperty");

 

0
Peter
Telerik team
answered on 06 Feb 2012, 01:00 PM
Hello Zain,

I am happy that you managed to resolve this case.

Do not hesitate to write back in case you need further help.

Greetings,
Peter
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Tags
DropDownList
Asked by
Zain
Top achievements
Rank 1
Answers by
Zain
Top achievements
Rank 1
Peter
Telerik team
Share this question
or