Jidesh Guptha
Top achievements
Rank 1
Jidesh Guptha
asked on 26 Oct 2010, 09:18 AM
Hi,
I am using the Inline insert and update feature of RadGrid, I have to validate the values entered if its blank i have to set the old value. Pls help me how to go about it.
regards
Jidesh
I am using the Inline insert and update feature of RadGrid, I have to validate the values entered if its blank i have to set the old value. Pls help me how to go about it.
regards
Jidesh
3 Answers, 1 is accepted
0
Hello Jidesh,
You can use RadGrid's UpdateCommand to extract your edited values, check if any of them is null and restore the previous saved values:
Veli
the Telerik team
You can use RadGrid's UpdateCommand to extract your edited values, check if any of them is null and restore the previous saved values:
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e){ GridEditableItem editItem = (GridEditableItem)e.Item; //extract the edited values in a Hashtable Hashtable values = new Hashtable(); editItem.ExtractValues(values); //get the saved old values before editing Hashtable oldValues = (Hashtable)editItem.SavedOldValues; //will hold the names of all fields that have null values List<object> nullFieldNames = new List<object>(); //get the field names that have null values foreach (DictionaryEntry entry in values) { if (entry.Value == null) { nullFieldNames.Add(entry.Key); } } //replace null with the original values foreach (object key in nullFieldNames) { values[key] = oldValues[key]; } //at this point Hashtable "values" contains the edited values //as well as the original values for all fields that had null}Veli
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Mark
Top achievements
Rank 1
answered on 20 Jan 2011, 11:41 PM
How can you do the same thing but not using the updatecommand.
I have my own command "SaveAll" which is saving multiple rows at a time, how do i get the SavedOldValues for these rows?
Currently the SavedOldValues just has null for the values.
I have my own command "SaveAll" which is saving multiple rows at a time, how do i get the SavedOldValues for these rows?
Currently the SavedOldValues just has null for the values.
0
Hi Mark,
Using the same approach, only you need to loop over all the edited items in RadGrid:
Veli
the Telerik team
Using the same approach, only you need to loop over all the edited items in RadGrid:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e){ if (e.CommandName == "SaveAll") { foreach (GridItem item in RadGrid1.EditItems) { GridEditableItem editItem = (GridEditableItem)item; //extract the edited values in a Hashtable Hashtable values = new Hashtable(); editItem.ExtractValues(values); //get the saved old values before editing Hashtable oldValues = (Hashtable)editItem.SavedOldValues; //will hold the names of all fields that have null values List<object> nullFieldNames = new List<object>(); //get the field names that have null values foreach (DictionaryEntry entry in values) { if (entry.Value == null) { nullFieldNames.Add(entry.Key); } } //replace null with the original values foreach (object key in nullFieldNames) { values[key] = oldValues[key]; } //at this point Hashtable "values" contains the edited values //as well as the original values for all fields that had null } }}Veli
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.