In here I have a RadDropDownList which is populated by a SQLDataSource.
My issue is: when a user clicks Edit on a row and the dropdown is displayed, how do I have the dropdown select the row's value from the list?
Similar to how the textbox is populated with:
What is the equivalent for dropdown?
4 Answers, 1 is accepted
Set the SelectedValue property:
I hope this helps.
See What's Next in App Development. Register for TelerikNEXT.
I have a similar issue, but when I add the SelectedValue to the RadDropDownlist and run it, I get an error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."
My RadDropDownList is inside an edititemtemplate of a RadDataForm.
Does the binding to the RadDataForm record have to be done only in code behind?
I assume that the RadDropDownList is being bound on the server instead of using Declarative DataSource with DataSourceID property. If that is the case, selecting the item also has to be done on the server. For that you can use the ItemDataBound event of RadGrid, based on the cell's value you can loop through the
For example, there is the following GridTemplateColumn with a RadDropDownList in its EditItemTemplate. The DropDownList is wired up to its Load server-side event used for binding data to it.
C# RadDropDownList Load event handler:
Finally, in the ItemDataBound event handler of the RadGrid, you can get a reference to the RadDropDownList control, find the DropDownItem with the same value as the one bound to the cell and make it selected.
- Accessing Cells and Rows
- GridItem type for edit mode
- Telerik RadGrid Data Binding Basics
- RadDropDownList - Data binding, to DataTable
I hope this will help resolve the issue.