HI,
I am using the RAD Grid in sharepoint 2010.
I have the following code in the update command:
How to get the changed values?
Thanks
I am using the RAD Grid in sharepoint 2010.
I have the following code in the update command:
protected
void
RadGrid1_UpdateCommand(
object
sender, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item
as
GridEditableItem;
DataTable ordersTable =
this
.GridData;
//Locate the changed row in the DataSource
string
filter =
"Title = '"
+ Convert.ToString(editedItem.OwnerTableView.DataKeyValues[e.Item.ItemIndex][
"Title"
]) +
"'"
;
// here Title='1' is shown. 1 is the value which is changed to 2.
DataRow[] changedRows = ordersTable.Select(filter);
if
(changedRows.Length != 1)
{
RadGrid1.Controls.Add(
new
LiteralControl(
"Unable to locate the Order for updating."
));
e.Canceled =
true
;
return
;
}
//Update new values
Hashtable newValues =
new
Hashtable();
//The GridTableView will fill the values from all editable columns in the hash
// in the below code newvalues is coming as empty
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
DataRow changedRow = changedRows[0];
changedRow.BeginEdit();
try
{
foreach
(DictionaryEntry entry
in
newValues)
{
changedRow[(
string
)entry.Key] = entry.Value;
}
changedRow.EndEdit();
}
catch
(Exception ex)
{
changedRow.CancelEdit();
RadGrid1.Controls.Add(
new
LiteralControl(
"Unable to update Orders. Reason: "
+ ex.Message));
e.Canceled =
true
;
}
ordersTable.AcceptChanges();
this
.GridData = ordersTable;
RadGrid1.DataBind();
}
How to get the changed values?
Thanks