My RadGrid is setup to perform bulk edits, and that is all working well. So this works great:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) {
if (e.CommandName == "UpdateAll") {
SaveTableData(e);
}
I'm preforming the Update/Insert like this:
foreach (GridEditableItem editedItem in RadGrid1.EditItems) {
Hashtable newValues = new Hashtable();
//The GridTableView will fill the values from all editable columns in the hash
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
}
However, when i add Paging to the mix, then the updates/inserts of the data are lost. That is, if the user enters in all their data, and then forgets to Save their data and instead moves to the next page of the bulk edit table, then the data they entered is lost.
So I aded this function to try to fix that:
protected void RadGrid1_PageIndexChanged(object source, GridCommandEventArgs e) {
SaveTableData(e);
}
But this 'e' does not have the user's new data that they entered in.
Why does the 'e' not have the new values?
7 Answers, 1 is accepted
The paging command event arguments object has the purpose of storing information about the paging operation, such as new page index for example, and is not related to editing. If you need to save the information, you should traverse the edit items, extract their new values, remember on which page those items are, and their item indexes too (so that you be able to put them back into edit mode).
Hope this helps.
Greetings,
Tsvetoslav
the Telerik team
foreach (GridEditableItem editedItem in RadGrid1.EditItems) {
Hashtable newValues = new Hashtable();
//The GridTableView will fill the values from all editable columns in the hash
e.Item.OwnerTableView.ExtractValuesFromItem(newValues,
editedItem);
}
The correct code is as follows:
foreach
(GridDataItem editedItem
in
RadGrid1.EditItems) {
Hashtable newValues =
new
Hashtable();
//The GridTableView will fill the values from all editable columns in the hash
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem.EditFormItem);
}
Regards,
Tsvetoslav
the Telerik team
protected void RadGrid1_PageIndexChanged(object source, GridPageChangedEventArgs e) {
}
protected void RadGrid1_PageIndexChanged(object source, GridCommandEventArgs e) {
}
And I verified that the
RadGrid1_PageIndexChanged
function is executed, but for some reason "editedItem.EditFormItem" is always null:if (null != editedItem.EditFormItem) {
ePageChanged.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem.EditFormItem);
So I'm unable to save any of the rows of data that the users might have added if they click on one of the paging links. Please advise. Should I send a sample project?
protected void RadGrid1_PreRender(object sender, System.EventArgs e) {
foreach (GridItem item in RadGrid1.MasterTableView.Items) {
if (item is GridEditableItem) {
GridEditableItem editableItem = item as GridDataItem;
editableItem.Edit = true;
}
}
RadGrid1.Rebind();
}
Could you specify what type of EditMode are you using? Is it InPlace? Is it also possible that you paste your whole aspx and code-behind.
Best wishes,
Tsvetoslav
the Telerik team
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) {
But this does:
protected void RadGrid1_ItemCommand(object source, EventArgs e) {