I have a RadGrid. In the RadGrid I have some GridTemplateColumns. In the EditItemTemplate I have a RadDropDownList. The GridTemplateColumn has a DataField defined. My expectation is that when the page loads that the RadDropDownList in the EditItemTemplate should have a SelectedValue that matches the DataField. But the SelectedValue is the default (blank) first item in the dropdown list. As soon as I select something from the dropdown list everything is happy including the Label that is in the ItemTemplate shows the text value for the item I selected from the dropdown list.
It works if I use a GridDropDownColumn instead, but I cannot in this case as I need to trigger javascript stuff based on an item selected from the dropdown.
How do I make sure that when the page loads the dropdown list's selected value matches the column's DataField value? It seems it should work this way automatically.
<
telerik:RadGrid
ID
=
"grdAddresses"
runat
=
"server"
AutoGenerateColumns
=
"false"
DataKeyNames
=
"Uid"
OnNeedDataSource
=
"grdAddresses_NeedDataSource"
OnBatchEditCommand
=
"grdAddresses_BatchEditCommand"
OnPreRender
=
"grdAddresses_PreRender"
EnableViewState
=
"true"
AllowSorting
=
"false"
AllowPaging
=
"false"
>
<
MasterTableView
EditMode
=
"Batch"
BatchEditingSettings-EditType
=
"Row"
>
<
Columns
>
<
telerik:GridButtonColumn
CommandName
=
"Delete"
ButtonType
=
"ImageButton"
UniqueName
=
"DeleteColumn"
ImageUrl
=
"~/Images/clear-button-24x24.png"
HeaderStyle-Width
=
"4%"
></
telerik:GridButtonColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Type*"
DataField
=
"TypeUid"
UniqueName
=
"Type"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
/>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadDropDownList
ID
=
"ddlType"
runat
=
"server"
DataTextField
=
"DropDownListText"
DataValueField
=
"Uid"
DataFied
=
"TypeUid"
>
</
telerik:RadDropDownList
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Address*"
DataField
=
"Address"
/>
<
telerik:GridBoundColumn
HeaderText
=
"Supplemental Address"
DataField
=
"AddressSupplemental"
/>
<
telerik:GridBoundColumn
HeaderText
=
"City/Locality"
DataField
=
"LocalityName"
/>
<
telerik:GridTemplateColumn
HeaderText
=
"Country"
DataField
=
"CountryUid"
UniqueName
=
"Country"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
Text='<%# Eval("CountryUid") %>' />
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadDropDownList
ID
=
"ddlCountry"
runat
=
"server"
DataTextField
=
"DropDownListText"
DataValueField
=
"Uid"
OnClientSelectedIndexChanged
=
"countrySelectedIndexChanged"
>
</
telerik:RadDropDownList
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"State"
DataField
=
"StateUid"
UniqueName
=
"State"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
Text='<%# Eval("StateUid") %>' />
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadDropDownList
ID
=
"ddlState"
runat
=
"server"
OnClientItemsRequesting
=
"stateItemsRequesting"
OnClientSelectedIndexChanged
=
"stateSelectedIndexChanged"
>
</
telerik:RadDropDownList
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Postal Code"
DataField
=
"PostalCode"
/>
<
telerik:GridTemplateColumn
HeaderText
=
"County"
DataField
=
"CountyUid"
UniqueName
=
"County"
>
<
ItemTemplate
>
<
asp:Label
runat
=
"server"
Text='<%# Eval("CountyUid") %>' />
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadDropDownList
ID
=
"ddlCounty"
runat
=
"server"
OnClientItemsRequesting
=
"countyItemsRequesting"
>
</
telerik:RadDropDownList
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>