I have a RadGrid with a EditFormSettings/FormTemplate for editing specific records. My dropdownlist is populating as expected, but my selectedvalue is not selecting the existing value. Any help would be greatly appreciated. Thanks.
In my MasterTableView, I have
protected void MyEditForm_DataBinding(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)
{
GridEditableItem gridEditItem = (GridEditableItem)e.Item;
DropDownList dropDownList = (DropDownList)gridEditItem.FindControl("ContactMethod");
dropDownList.DataSource = customerData.GetLookupList("ContactMethodList");
dropDownList.DataBind();
dropDownList.SelectedValue = gridEditItem.GetDataKeyValue("ContactMethodID").ToString();
}
}
<
asp:DropDownList
ID
=
"ContactMethod"
runat
=
"server"
TabIndex
=
"2"
DataTextField
=
"Display"
DataValueField
=
"LookupID"
AppendDataBoundItems
=
"true"
>
<
asp:ListItem
Text
=
""
Value
=
"0"
></
asp:ListItem
>
</
asp:DropDownList
>
In my MasterTableView, I have
DataKeyNames
="CaseId, ContactMethodID"