Replies
[quote user="EddieMu"]
My grid is bound to a BindingNavigator control. This is linked to a binding source that is bound to a dataset object. Clicking on the Delete button on the BindingNavigatorcontrol does remove the row from the grid but does not remove the record from the underlying data table.
I added a DataTable.AccpetChanges() command in the AfterRowsDeleted event of the grid but no luck.
Any ideas?
[/quote]
Sorry, I have no experience with BindingNavigator stuff. If you saving row by row and not using a DataAdapter, you will be iterating through the rows in the DataTable that you're saving, and you can check the RowState of the row to see if it's deleted or whatever. That's all I can think of.
Good luck,
J
[quote user="EddieMu"]
I have t he same problem and your proposed solution doesn't work for me. Where are you putting this .AcceptChanges call?
[/quote]
At the beginning of my Save function. So here's an example of how it looks:
1. DataTable is loaded as grid DataSource–DataTable has 3 rows, grid has 3 rows.
2. User deletes 2 rows out of grid; the grid has 1 row, the DataTable still has 3 (2 of which are in RowState.Deleted).
3. User clicks Save & Exit button. In my Save() function, at the beginning, the DataTable still has 3 rows. I call AcceptChanges on it immediately, and now it has 1 row.
I hope this works for you, it's been a while since I looked at this.
–J
Yes, my stupid self just figured out how to get it working–AcceptChanges(). To all the others on this thread, call AcceptChanges on your DataTable to see the rows removed.
Sorry for the novice question.
Mike,
I am having the same problem–I have an UltraGrid (bound to a DataTable) with a button column for delete, and on the click event I call e.Cell.Row.Delete(false) and the row is removed from the grid.
In my Save function (called from when the user clicks an OK button outside the grid), I call UpdateData on my UltraGrid. The grid shows 1 row, and the DataTable has 2. Granted, the rowstate of one of them is Deleted, but it seems like it should be gone.
Is that correct behavior?
Thanks,
J
Mike,
In regards to your first point, do BeginUpdate/EndUpdate and/or SuspendRowSynchronization/ResumeRowSynchronization need to be used when just binding the data source to the grid?
Example:
try
{
DataTable dtTable = myDAO.GetTable();
ugGrid.BeginUpdate();
ugGrid.SuspendRowSynchronization();
ugGrid.DataSource = dtTable;
}
catch ….
finally
{
ugGrid.ResumeRowSynchronization();
ugGrid.EndUpdate();
}
Just wondering if there's any performance benefit to that approach, or if the control already suspends itself until InitializeLayout and all InitializeRow events have completed.
Thanks,
Jamal
Mike,
Regarding number 2, if my column style is set to something like Button or DropDownList, should I leave the CellDisplayStyle to the default Editor? Also, if a column is hidden in Initialize_Layout, should I still set its CellDisplayStyle for a performance benefit?
Nice article, thanks.
–J