Validation with DataBinding?

blumenhause

Member
Joined
Jun 27, 2006
Messages
5
Programming Experience
Beginner
Hello,

I am a new member of this forum and a beginner in software development.. I am working with a software company here in India as a Trainee Software Engineer..I use the Internet and MSDN to the max but still has this doubt..

I am creating a Patient Registration form for a Hospital Management Software..And I have to use DataBinding for populating the TextBoxes and DateTimePicker with data from the DataGrid.. DataSource is a DataSet and backend has SQL Server 2000..

I have binded the TextBoxes and DateTimePicker to the appropriate columns in the Grid, but would like to know how i can achieve data Validation before the Database is updated.. Validation - say, check the value entered in "Age" TextBox, validate the Date selected in the DateTimePicker, check if the CheckBox of DateTimePicker is checked or not..

Any help would be greatly appreciated.. I lack experience, so excuse my mistakes, if any..

I really appreciate any assistance in this regard.

Manoj

P.S: I couldn't find much resources on the Internet related to controls like DateTimePicker or DataGrid in VB.NET, could anyone provide some online links that has more information on such resources or some Books..
 
in vs2005 i would, prior to committing the data to the database, I would:

request a copy of the changed rows with
VB.NET:
Dim chg as DataTable = myDataTable.GetChanges(DataRowState.Added + DataRowState.Modified)
then scan each row:
VB.NET:
For Each r as DataRow in chg.Rows
if DirectCast(r("Age"), Nullable(Of Decimal)).Value < 1 then ...
*note that age will need converting/casting into its relevant type. It might be a System.Nullable(Of Decimal) in which case, cast it into a nullable decimal and request the value


if a row violates the rules, you can inform the user, switch to that row, etc..
 
Last edited by a moderator:
Back
Top