all groups > dotnet windows forms databinding > january 2005 >
You're in the

dotnet windows forms databinding

group:

Trapping Datagrid Error Message


Trapping Datagrid Error Message Paul J. Lay
1/25/2005 11:25:31 AM
dotnet windows forms databinding:
BlankI have a WinForm app that uses a datagrid which is bound to a .Net =
dataset. After data is entered incorrectly into one of the datagrid =
cells and the update button on the form is selected, I get an embedded =
message box displaying the error, e.g. "Error when committing row to the =
original data store." Column xxxx does not allow nulls. Do you want to =
correct the value?" The cursor is not set to the correct cell. I =
would like to trap this error message, display my own error message and =
set the datagrid cursor to the correct cell. I am having difficulting =
trapping this message. How can I do this? Thanks for your help.

Best Regards,

Re: Trapping Datagrid Error Message Paul J. Lay
1/26/2005 6:13:23 AM
Thank you for your prompt reply which was excellent from my perspective.

Best Regards,

Paul J. Lay

[quoted text, click to view]

RE: Trapping Datagrid Error Message v-jetan NO[at]SPAM online.microsoft.com (
1/26/2005 7:05:32 AM
Hi Paul,

Thanks for your posting!

Yes, this is a frequented asked question about DataGrid databinding. In the
datasource datatable, if certain datacolumn's AllowDBNull property is
false, passing null value to the datasource will result in an exception,
and DataGrid databinding will catch this exception and display to the
customer.

Currently, there is no way to hook into the databinding process of
DataGrid, so we should do validation at the UI level. For a start, please
refer to:
"5.20 How can I do cell by cell validation in a datagrid?"
http://64.78.52.104/FAQ/WinForms/FAQ_c44c.asp#q773q

But, the above cell by cell validation also has problem when we did not
touch the need validation cell then move to another row. So, we have to
extend the below article's code, then the user changes current cell, just
determine if he changes to another row(or only the different cell change in
the same row). If the user changes the current row, just do the valition
for the entire row validation for the original row.

Hope this information makes sense to you.
========================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Re: Trapping Datagrid Error Message v-jetan NO[at]SPAM online.microsoft.com (
1/27/2005 2:35:49 AM
Cool, you are welcome!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
AddThis Social Bookmark Button