On a regular formview against an objectDataSource, we define the method for the Updating event to add values to the item that is being edited, something like this:
protected void MyFormView_ItemUpdating(object sender, FormViewUpdateEventArgs e)
{
RadComboBox countriesCombo =
(RadComboBox)MyFormView.FindControl("CountryRadComboBox");
// this should never be null, other wise, error is shown
if (!string.IsNullOrEmpty(countriesCombo.SelectedValue))
e.NewValues["CountryId"] = countriesCombo.SelectedValue;
In a RadGrid, I am using an edit form. Insert is working great putting this code in the PerformInsert event method:
GridEditFormInsertItem gridItem = (GridEditFormInsertItem)e.Item.OwnerTableView.GetInsertItem();
Hashtable values = new Hashtable();
gridItem.ExtractValues(values);
values["ReferenceId"] = 0;
RadComboBox comboCountries = (RadComboBox)gridItem.FindControl("CountryRadComboBox");
values["CountryID"] = comboCountries.SelectedValue;
e.Item.OwnerTableView.InsertItem(values);
However, trying to do the same for edit is not working for me. It is the last step that I am not being able to do. Once I change the hashtable values with the value in the combo, how do I indicate that it has to use these values?
In the telerik examples they work it out with a DataTable obtained from the datasource and then mapping and doing the update in the code…. don’t wanna do that, i would love it would work the same way the insert does. For the case when i dont need to change any value in the hashtable it works perfectly, the update is working.
Any help appreciated
Vladimir
If I’m not mistaken, the extracted values should already be set to the selected value of the dropdown. Try using
Bindto set the selected value in the markup: