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

GridEditableItem DropDownList SelectedValue (Help Needed)

1 Answer 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karl Rohrbach
Top achievements
Rank 1
Karl Rohrbach asked on 27 Jan 2011, 05:54 PM
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.

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"

 

1 Answer, 1 is accepted

Sort by
0
Karl Rohrbach
Top achievements
Rank 1
answered on 27 Jan 2011, 06:05 PM
After hours of sifting through different solutions and troubleshooting my own application, I found out I was binding my master key value to the wrong ID.  Ooops.  

Does anyone have any good examples of using a radio button list in the GridEditableItem scenario?
Tags
Grid
Asked by
Karl Rohrbach
Top achievements
Rank 1
Answers by
Karl Rohrbach
Top achievements
Rank 1
Share this question
or