We can edit the items /rows of a RadGrid in three ways either using a EditFormTemplate / using a new page for its edit mode / by using inplace editor of the RadGrid.
If we used item template for the RadGrid to view or edit its data then we have to get the instance of the control to work with the data used within the template. So here i have explained how to get the edit item template control in edit mode from particular row.
1) First of all we have to get the particular item which is currently
in edit mode.
Ex :-
In the handle of the UpdateCommand event of the RadGrid(lets say ‘rgMyGrid’ here)
Get the edited item as follows :
GridEditableItem editedItem = (GridEditableItem)e.Item;
Here editedItem is the item which is in edit mode currently.
2) Then if we want lets say the dropdown control from a particular cell of the currently edited item then we have to code like below :-
Ex :
RadComboBox ddlMyComboBox = (RadComboBox)editedItem["ColumnUniqueName"].FindControl("ComboBoxID");
Here we have to pass the column name to the editedItem as indexed variable.
Then passing the control id to the FindControl() method we can get the instance of the particular combo box
control resides within the particular cell.
Now here ‘ddlMyComboBox’ is the instance of the control from which we can get data through properties like Text/SelectedValue/SelectedItem etc.