Attempting to use an XmlDataSource to populate the values in a dropdown list control in a GridTemplateColumn edit and insert templates.
Searched over:
1 - using ASP datasources: https://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/data-binding/binding-to-asp-datasource-components
2 - using inline XML in an XmlDataSource: http://www.java2s.com/Code/ASP/XML/UsingInlineXMLDatainanXmlDataSourceControl.htm
3 - fixing the 'GridInsertionObject does not contain a property named 'X' ' error: https://weblogs.asp.net/kencox/fixing-the-telerik-webcontrols-gridinsertionobject-does-not-contain-a-property-error
4- Populating a dropdownlist in a datagrid template column: https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/Common/radcombobox-in-radgrid
* Yes, the links above reference the combobox control, presumably the dropdown list functions the same way.
Goal: Populate a DropDown list using an XmlDataSource and inline XML
Problem: it does not work.
Looking for the proper format of the inline XML to get this to work.
Links 1 and 4 say that the XML file has to be formatted as <items><item>, but this causes an error when inline stating that 'items' is invalid'
Links 2 say to use <Data><items><item>, which doesn't throw an error but doesn't load
Using the method from Link 3 to set the default values, I avoid the GridInsertObject error, but the defaulted value is not bound.
<
telerik:GridTemplateColumn
HeaderText
=
"Wpn Qual"
DefaultInsertValue
=
"M"
>
<
ItemTemplate
><%#DataBinder.Eval(Container.DataItem,"WPN_QUAL_BADGE") %></
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadDropDownList
runat
=
"server"
ID
=
"ddlWpnQual"
DataTextField
=
"Text"
DataValueField
=
"Value"
DataSourceID
=
"xmlWpnQual"
SelectedValue='<%#Bind("WPN_QUAL_BADGE") %>' ></
telerik:RadDropDownList
>
</
EditItemTemplate
>
<
InsertItemTemplate
>
<
telerik:RadDropDownList
runat
=
"server"
ID
=
"ddlWpnQual"
DataTextField
=
"Text"
DataValueField
=
"Value"
DataSourceID
=
"xmlWpnQual"
SelectedValue='<%#Bind("WPN_QUAL_BADGE") %>' ></
telerik:RadDropDownList
>
</
InsertItemTemplate
>
</
telerik:GridTemplateColumn
>
<
asp:XmlDataSource
ID
=
"xmlWpnQual"
runat
=
"server"
XPath
=
"Data/Items"
>
<
Data
>
<
Items
>
<
Item
Text
=
"-- Select --"
Value
=
""
/>
<
Item
Text
=
"Marksman"
Value
=
"M"
/>
<
Item
Text
=
"SharpShooter"
Value
=
"S"
/>
<
Item
Text
=
"Expert"
Value
=
"E"
/>
</
Items
>
</
Data
>
</
asp:XmlDataSource
>
And yes, I can manually create the items via markup in each instance of the dropdownlist... I would prefer to use a scalable approach in this specific instance.