Hi,
I have a DataGridView bounded to a database table. I'm trying to validate a row entered by a user with the RowValidating event. What i want to do is check if the user entered a value already in the database. The problem is that when the RowValidating event is fired, the IsNewRow property is already set to false, but the value is not in the DataTable yet.
For example, if the user adds a new row in the database, I check in my DataTable if the value is already there. If so, I show an error message. But if the user doesn't create a new row and renames one with an already existing value, the error message will pop because the value is already there.
That's why I tried to use the IsNewRow property, to know if we're dealing with a new row or just an edit. But the value is always false, event when I'm adding a new row.
So, how can I know that the user is add a new row? And is there a better way to check for duplicate?
Thank you!