Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Ultrawingrid UpdateData Method.
posted

I have two tabs in my form. Add and Update. I have two Ultragrids(grdAdd and grdUpdate) that bind data. I am facing a peculiar problem for the update grid which is used to retrieve data from database bind it and display on the screen. Apart from the columns from the database i have added a few hidden columns for validation. Any time user changes a cell value in any row and hits Save i have the following:

grdAdd.UpdateData();
grdUpdate.UpdateData();

If(ValidationPasses)

{

DataTable table;
DataTable source = (DataTable)grid.DataSource;
//For the update grid, only update modified rows

if (update)
{
DataTable updates = ((DataTable) (grid.DataSource)).GetChanges(DataRowState.Modified);
var modifiedRows = from x1 in updates.AsEnumerable()
join x2 in source.AsEnumerable()
on x1["RowIDX"] equals x2["RowIDX"]
select x1;
table = modifiedRows.CopyToDataTable<DataRow>();
}
else
{
table = (DataTable)grid.DataSource;
}

}

The problem is if any cell value is changed then GetChanges just gives me only the row that was changed. But if any cell value is deleted and Save was hit, i display a message saying cell value is provided. After the value is provided i notice AfterCellUpdate event being triggered for additional rows that what was selected and the UpdateData method on Save marks all the rows as modified so the GetChanges results in all rows being modified. Can you please help me how to fix this. 

How to get only the rows where cells have been edited as rows that are marked as Modified.