I have an ultragrid, it is bound to a bindingsource, this binding source is created by BindingSource= new bindingsource(dataset, "TableName"), and then datagrid.datasource=BindingSource.
When I delete one row in the datagrid, that is is disappeared, but in the dataset, that record is still existed in the datatable, and the RowState is "unchanged".
so the record is deleted from datagrid, but not deleted from datasource.
who can help me with this?
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.
The behavior you are getting is correct. The grid sends a notification to the data source to delete the row. A DataTable does not delete the row when it gets this notification - it just marks the row as deleted. It does this so that it can keep track of deleted rows for when you eventually update the back end.
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
painted8 said:I'd like to use the grid's functionality of selecting rows, hitting Del on the keyboard, and their prompt. Records are gone from the grid. Now to really delete them.
What do you mean by "Now to really delete them?" I assume that this is a typo and that you meant to type "Not" instead of "Now. But I'm still not clear on what you mean. If you are using the grid's functionality to delete rows then the rows will get deleted from the data source.
painted8 said:So I'm in AfterRowsUpdated. How do I access the index of the row(s)? I'd rather access an ID field, but don't know how to get focus of either.
There is no AfterRowsUpdated event that I am aware of. There's an AfterRowUpdate event, but this fires for a single row update, and has nothing to do with the deletion of rows. For deleting, you would use Before/AfterRowsDeleted. The event passes you a list of the rows, I think. Or if not, then you can use the grid.Selected.Rows collection.
I'd like to use the grid's functionality of selecting rows, hitting Del on the keyboard, and their prompt. Records are gone from the grid. Now to really delete them.
So I'm in AfterRowsUpdated. How do I access the index of the row(s)? I'd rather access an ID field, but don't know how to get focus of either.