How can I validate row deletion in c# using dataview???
I'm developing an automation system using Visual Studio .net.
First, I found .net framework very user frendly, very intuitive, strongly OO and very nice to program with. But sometimes I get angry with persistent data handling. I'm new to .NET, but since I've programmed in a lot of diferent languages before, I thought it would be easy. Well, it is easy, except System.Data namespace.
For example, I'm using a databank that does't have integrity constraints. To validate delection, for example, I thougth I should find the corresponding event on dataview, search the foreing key, and then, cancel deleting if the key is found. Then I found the RowDeleting event... but didn't worked. I can't cancel the deletion there. I searched the internet, and I found this:
http://dotnet247.com/247reference/msgs/5/28321.aspx
So, it's not possible to that there... Well, and tried RowDelete too, but it's not the best solution, because I don't want to rollback all the changes at the row, but JUST cancel deleting....
What's the best way to do this?
Probably, there is a easy e obvius way to do it, but I can't find.
Thanks in advance, and sorry for my English.
No reply? It's crazy, I thought a lot of people was using System.Data namespace from .NET framework... :)
Quote:Original post by manuelb
So, it's not possible to that there... Well, and tried RowDelete too, but it's not the best solution, because I don't want to rollback all the changes at the row, but JUST cancel deleting....
What's the best way to do this?
Before RowDeleting occurs, RowUpdating occurs (see here). Capture the RowUpdating event. If this row should be skipped (perform your validation) and it's a deletion (check the event arguments to see if it's StatementType.Delete), then set the UpdateStatus parameter to SkipCurrentRow. This cancels processing for that row.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement