ekenman
asked on
Error Handling in DatagridView
I have a Datagridview that is bound to a dataset.
The datagridview contains four columns:
1. Dropdownlist of Companies
2. Dropdownlist of Accounts
3. Textbox: Debit Amount
4. Textbox: Credit Amount
The dataset does not allow null values in the 1,2 column.
In the datasets Partial Class I've added Error Handling for this and they show up in the Datagridview as they should.
However, the user is allowed to leave the row even though there are errors on the rows columns. When this happens, the DataGridViews DataError event is thrown and the users row is deleted. How to avoid this? Is there a post row change event that can check for errors?
Best Regards
Tomas
The datagridview contains four columns:
1. Dropdownlist of Companies
2. Dropdownlist of Accounts
3. Textbox: Debit Amount
4. Textbox: Credit Amount
The dataset does not allow null values in the 1,2 column.
In the datasets Partial Class I've added Error Handling for this and they show up in the Datagridview as they should.
However, the user is allowed to leave the row even though there are errors on the rows columns. When this happens, the DataGridViews DataError event is thrown and the users row is deleted. How to avoid this? Is there a post row change event that can check for errors?
Best Regards
Tomas
perhaps better:
DataGridView..::.RowValida ting Event
Occurs when a row is validating.
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.rowvalidating.aspx
DataGridView..::.RowValida
Occurs when a row is validating.
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.rowvalidating.aspx
ASKER
The DataError is thrown before both the other events and erases the row....
Hi,
If you are using DropDownList in Datagridview then you will be using EditItemTemplate isn't? They you can use RequiredFieldValidator for the DropDownList and validate the input.
If you are using DropDownList in Datagridview then you will be using EditItemTemplate isn't? They you can use RequiredFieldValidator for the DropDownList and validate the input.
ASKER
That sounds perfect Giftson. I'm not sure where I'll find EditItemTemplate and RequiredFieldFalidator.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oh... This is a Windows Client and not ASP. I presume you are talking about switching to code view from html?
Okay. Then it is wrongly posted in Asp.Net Zone.
ASKER
Ooops... Sorry about that one. I'll try to correct this...
ASKER
I'll assign you points anyway since you answered it and start a new question in the right forum.
ASKER
Thank's!
DataGridView..::.RowLeave Event
Occurs when a row loses input focus and is no longer the current row.
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.rowleave.aspx