ADO .NET Data Validation 2.0

G

Guest

Hi All,

I am using VS 2005 and ADO.NET 2.0 to build a Windows Forms. I am
binding my data source to a datagridview and would like to know the following:

Where is the best place to perform data validation
(invalid/out-of-range column values, invalid text, etc...)? Do I perform it
in some DataGridView event before changing to the next row? If so, which
event? OR, do I use the partial class generated by the Dataset Designer. I
guess using the latter approach would be more application centric as I can
implement various forms and whatever is my "save" method, it would execute
the same validation processes on a per table and per column basis. What is
the best practice, or "new way of doing things" when it comes to data
validation with ADO .NET 2.0/VS 2005? Any examples or sample code of this?

Regards,

Giovanni
 
C

Cowboy \(Gregory A. Beamer\)

My personal preference is to validate on the business layer. As Microsoft
drag and drop drops out the business layer, this is only applicable when you
do not use the MS FUD. I will generally attempt to validate on the UI, as
well, to avoid trips, but you should always validate before attempting a
data run.

If you are using a DataGrid view to edit individual records, you end up with
a button click event to submit back. You can run a validation check here.
The code, as mentioned, should be in the business layer, but you can thin
that out to start and refactor later, if it makes your life easier. If your
DataSets are strongly typed, you have the option of using them for some, if
not all, of your validation.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***********************************************
Think Outside the Box!
***********************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top