first of all congratulations for you suite, i find it to be the best asp.net suite ever!
I have the following problem,
i want the user to be able to perform multiple, concurrent edits in a radgrid and the update them all together.
I found a sample of yours regarding "batch update" which works perfect and i have set the AllowMultiRowEdit="True" so that the user can edit multiple rows.
The problem is that if a user begins editing one row, changes some data and THEN begins editing another row, although both of these rows will be in edit mode, all the changes before the last "Edit" Command will be lost!
I have checked this with your samples too and they have the same malfunction ( or functionality :) ).
I tried to get the existing data from the previous editing rows inside the RadGrid1_ItemDataBound event like this:
if (e.Item is GridDataItem && e.Item.IsInEditMode) |
{ |
GridEditableItem dataItem = e.Item as GridEditableItem; |
dataItem["AutoGeneratedEditColumn"].Controls[0].Visible = false; |
Hashtable newValues = new Hashtable(); |
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, dataItem); |
string sPosition = (dataItem["Position"].Controls[0] as System.Web.UI.WebControls.TextBox).Text; |
} |
Neither newValues nor sPosition has the changed values for the previously edited items.
They all have the original values.
Is there any workaround?
Thanks in advance!
11 Answers, 1 is accepted
The described behavior is actually expected. If the user edits several rows and then updates only one, or tries to edit another row, the grid will rebind itself and all modified data on client side will be lost. I can suggest you allow the users edit and update only selected rows. Please examine this online demo which implements this approach.
You cannot retrieve the client modifications in ItemDataBound event handler, because the grid does not know about these changes when it rebinds itself. You can write some JavaScript functionality in order to watch whether the data is modified. Here is an online demo which illustrates similar functionality.
Best regards,
Georgi Krustev
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.

I can get as far as extracting my new values in the code, but I'm just stuck at how to update the matching data item in the grid..
protected void radgrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
// if user is editing an item, try to keep the latest state of changes for other items in edit mode also |
if (e.CommandName == "Edit") |
{ |
foreach (GridDataItem dataItem in radgrid1.EditItems) |
{ |
Hashtable editValues = new Hashtable(); |
e.Item.OwnerTableView.ExtractValuesFromItem(editValues, dataItem); |
// tried the lines below, but it doesn't work because it just updates the control in the current edititem (which has the new values, not old). |
TextBox itemValue = (dataItem["TASK_DESCRIPTION"].Controls[0] as TextBox); |
itemValue.Text = editValues["TASK_DESCRIPTION"].ToString(); |
// how to access and update the actual data item from here??? |
} |
} |
} |
I will suggest you to examine this online help article, which shows how to implement the requested behavior.
I just want to draw your attention to the end of the suggested article. There is a method which describes how to hide the Update and Cancel buttons in order to avoid any misunderstanding by the user. This code will work only if you use the "In-Place" edit mode. If you are using EditTemplate for editing of the row, you need to modify like so to hide the buttons:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridEditFormItem && e.Item.IsInEditMode) //if the item is a GridEditFormItem |
{ |
var item = e.Item as GridEditFormItem; |
var update = e.Item.FindControl("UpdateButton") as Button; |
var cancel = e.Item.FindControl("CancelButton") as Button; |
update.Visible = false; |
cancel.Visible = false; |
}} |
Kind regards,
Georgi Krustev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

For anyone else that might read this post (and if George is still following it), my fix was basically placing something like this in place of my last code snippet:
// first must declare a public DataTable in the code (similar to article) |
protected void radgrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
// if user is editing an item, try to keep the latest state of changes for other items in edit mode also |
if (e.CommandName == "Edit") |
{ |
foreach (GridDataItem dataItem in radgrid1.EditItems) |
{ |
// get the old row in the DataTable |
string myKeyField = "ROW_ID"; |
string sqlSelect = "ROW_ID = '" + editedItem.GetDataKeyValue(myKeyField).ToString() + "'"; |
DataRow[] changedRows = myDataTable.Select(sqlSelect); |
// get the updated fields |
Hashtable editValues = new Hashtable(); |
//The GridTableView will fill the values from all editable columns in the hash |
editedItem.OwnerTableView.ExtractValuesFromItem(editValues, editedItem); |
// update the datatable row (note: this is not the actual database table) |
DataRow changedRow = changedRows[0]; |
changedRow.BeginEdit(); |
try |
{ |
foreach (DictionaryEntry entry in editValues) |
{ |
changedRow[(string)entry.Key] = entry.Value; |
} |
changedRow.EndEdit(); |
} |
catch (Exception) |
{ |
changedRow.CancelEdit(); |
} |
} |
} |
} |

Your comments are indeed meaningful and right on target. We will consider creating a new RadGrid online example (for the next major release of the product) which to illustrate how to perform client-side editing with batch updates and keep the information in the edited cells when editing more items.
The next release of our controls is planned in the beginning of March while a Beta version is scheduled in the middle of February. I hope that you will find the new sample useful and will be expecting your feedback on it.
Kind regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

i am working on multiple edit .... in my grid all rows are editable initial and there is an command button update all . when user clicks on that button all rows should be updated . i am facing problem in how to identify which rows are changed ... i mean suppose initialy i have 10 rows in edit mode and user modify only 5 rows ... then in my command how will i know that this row is modified or not ?
thanks in advance

Hello everyone,
I have some problem with RadGrid multi row option, detailed as below.
I have One RadGrid with property allowmultirow=”true” & have embedded Usercontrol for edit operation.
Have command item template with commandname = “UpdateAll” which will update all the rows which were in edit mode.
In order to set row in edit mode, I have used edit command column, which is an imagebutton.
So, whatever row user wants to edit, he will click on that imagebutton & the UserControl will be loaded with all the relevant data, user will do the same for all the rows which he wants to edit,
And after that he will click on Updateall button, which will call the itemcommand event of grid and update all the data.
Now, the problem is while user click on edit command column my user control will be loaded with all its prerender, init event for the selected row.
After that suppose I make some changes in the some of the fields of user control, say we have textbox with user name which was initially loaded blank & I make changes it to ‘XYZ’.
Now again I select another row for edit operation. So again my user control will be loaded for this row as well as the previous row which I have selected.
So, whatever changes I have been made previously i.e. set user name = ‘XYZ’ from blank, will be again set to Blank,
WHY USERCONTROL IS LOADED FOR THE PREVIOUS ROW ????
That is my question, as it is degrading my applications performance,
As it is initialling user control for all the row which is in edit mode all the times, rather than calling it for the corresponding row selected and leaving other as it is. &
also initialize all the control and lose all the changes that I have made previously.
thnx in advance!!
I am using 2010.2.929.35 verson, Is the problem been solved in new version ??
Manoj
Could I kindly ask you to open a separate support ticket or a new forum post for the presented issue so we could better track the problem? Also note that providing your RadGrid markup as well as the related code behind will help us further investigate your scenario and do our best to isolate the root cause of the problem.
All the best,
Maria Ilieva
the Telerik team

Hi! Maria Ilieva,
I have already posted my forum @ following URL:
please see to it.
thanx,
Manoj Panchal
The described behavior is the expected behavior of RadGrid. AllowMultiRowEdit property is used to allow RadGrid to have more than one item in edit mode not to be able to edit the items independently. This behavior comes from the fact that when you put some item in Edit mode the Grid is rebound to the data and that is why the already opened editor are loaded with the value from the datasource and the user value is not persisted.
There are two possible work-arounds for this behavior:
One is to put all the needed items in edit mode before starting to manipulate any data. Then when the user click some button you could extract all the values and update all the records at once.
The other approach is to hook the ItemDataBound event and to store the already entered values in some container object like List or some other collection. Another approach is to hold the entered value on the client.
@mahima
The only way to know which row is modified is to use some kind of marker. You need either to save the old state and compare it with the new or on the client to set some field with the index of edited items. Then on the server you could check whether the current item has an index equal to one of the items that you stored on the client.
Regards,
Andrey
the Telerik team