Hello,
I have an datatable, bound to an UltraWingrid.
The idea is to allow the user to edit all cells he wants in the UltraWingrid.
Once he pressed an "update" button, the modifications will be written to the database.
I was hoping I could use following code (but it doesn't seem to work)
pseudocode ...
for each myrow in ugrid.rows
select case myrow.datachanged
case datachanged.added
'add record to the database
case datachanged.deleted
'delete record from the database
end select
next
I found this sample code at http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=8272, but it doesn't seem to work...
whatever "changes" the user makes, datachanged is always "false"
thanks in advance for your help
Grtz,
Johnny
Hi Johnny,
DataChanged doesn't really have any bearing on whether the changes are saved to the database. The grid only deals with the local data source - it has no connection to the back end.
So DataChanged only tells you if a change in the grid has not yet been saved to the local DataSource. And even then the DotNet BindingManager will automatically update the data source any time the current position changes. So if you move to another row in the grid, any changes in the previous row are automatically committed to the data source and so DataChanged would be false.
If you want to update your database in batches, then you need to use a DataSource that tracks the changes locally, like a DataTable or DataSet. This is between the data source and the database - the grid has no involvement in this process.
Can you please explain this further with an example. I have the same issue. I am trying to save multiple added or edited rows.
Thnx
All I do in this situation is have a hidden column called datachanged in the datagrid and set that to true after row update. I then loop down the grid for all those with that record set to true.
Not sure if it helps, but in my case, I have a DataTable as source for the grid, and the following worked for me:
foreach (var row in ultraGrid.Rows.Where( i => ((DataRowView)i.ListObject).Row.RowState != DataRowState.Unchanged))
{
.......
}
Hope this helps!