简体   繁体   中英

Dropdown column not binding selected value

I have a dropdown column in my radgrid. The values are defined in code behind:

 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{

     if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)
    {
        GridEditableItem editedItem = e.Item as GridEditableItem;
        GridEditManager editMan = editedItem.EditManager;
        GridDropDownListColumnEditor editor = editMan.GetColumnEditor("Designation") as GridDropDownListColumnEditor;
        editor.DataSource = new object[] { "TB", "Tram", "Hybrid", "Sub-systems", "Spare parts" };
        editor.DataBind();
    }
}

This is my markup:

  <telerik:GridDropDownColumn DataField="Designation" FilterControlAltText="Filter Designation column" HeaderText="Designation" UniqueName="Designation">
                                 <ColumnValidationSettings>
                                     <ModelErrorMessage Text="" />
                                 </ColumnValidationSettings>
                             </telerik:GridDropDownColumn>

I can select the value in the drop down when in edit mode but after updating/insert there is no value in the db. Is there something wrong in what I am doing?

As long as you can see your options in the dropdown you binding worked.

Since you don't show the code how you insert your data into DB, I can suggest several points of failure:

  1. What value do you insert? How you read it?
  2. What happens on the value change on client? Do you postback?
  3. Is this value passed to your server in your ViewState ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM