By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,812 Members | 1,288 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,812 IT Pros & Developers. It's quick & easy.

Deleting row from DataView (OT)

P: n/a
Hello;

Sorry for being a little off topic. I've posted to the ADO.NET group as
well :)

Dealing with Winforms on 1.1 framework, VS.NET 2003.

I have a DataView (which is the Data Source for a DataGrid), and I want to
be able to delete rows only if specific columns contain specific values.
For example, one of the columns contains boolean values; if the value for
the row we are attempting to delete is true go ahead and delete it, but if
it's false cancel the delete.

I have a handler hooked to the DataTable.RowDeleting event (the DataTable is
obviously the source for my DataView), which supposedly fires before the row
is deleted. In there, I check my column conditions, but what I need to know
is what do I call to cancel the deletion? I've tried DataRow.RejectChanges,
DataRow.CancelEdit, and DataTable.RejectChanges to no avail - the row always
disappears from the DataGrid, so I assume the row is being deleted from the
view. I step through the event, so it is being triggered and my condition
checking is accurate.

I also tried doing stuff in the DataView.ListChanged

Thanks for your help;

Derrick
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Derrick,

Instead of allowing people to delete through the data view/data table,
why not create a wrapper for accessing the rows (or at least, performing
actions on the rows) which will not perform the delete in the first place.

Then, you route all the calls through that.

Also, have you tried throwing an exception? This might be the only way
to get the operation to cancel.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Derrick" <de***********@hotmail.com> wrote in message
news:Ke********************@news20.bellglobal.com. ..
Hello;

Sorry for being a little off topic. I've posted to the ADO.NET group as
well :)

Dealing with Winforms on 1.1 framework, VS.NET 2003.

I have a DataView (which is the Data Source for a DataGrid), and I want to
be able to delete rows only if specific columns contain specific values.
For example, one of the columns contains boolean values; if the value for
the row we are attempting to delete is true go ahead and delete it, but if
it's false cancel the delete.

I have a handler hooked to the DataTable.RowDeleting event (the DataTable
is obviously the source for my DataView), which supposedly fires before
the row is deleted. In there, I check my column conditions, but what I
need to know is what do I call to cancel the deletion? I've tried
DataRow.RejectChanges, DataRow.CancelEdit, and DataTable.RejectChanges to
no avail - the row always disappears from the DataGrid, so I assume the
row is being deleted from the view. I step through the event, so it is
being triggered and my condition checking is accurate.

I also tried doing stuff in the DataView.ListChanged

Thanks for your help;

Derrick

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.