Validating a Dataset using Validation Blocks

Topics: Validation Application Block
Aug 4, 2009 at 8:51 AM
Edited Aug 4, 2009 at 8:53 AM

Hi All,

I have a requirement, i need to validate a dataset using validation blocks which is in the following format.

DataSet

DataTable orderInfoTable = new DataTable("OrderTable");

orderInfoset = new DataSet("OrderSet");

orderInfoTable.Columns.Add(n

orderInfoTable.Columns.Add(new DataColumn("OrderName"));

ew DataColumn("ID"));

DataRow

dr["ID"] = "id";

dr["OrderName"] = "ordername";

dr = orderInfoTable.NewRow();

orderInfoTable.Rows.Add(dr);

orderInfoset.Tables.Add(orderInfoTable);

Please let me know how this shall be achieved.

Thanks,

Prasenna

 

Aug 4, 2009 at 12:18 PM
Edited Aug 4, 2009 at 12:25 PM

Hi,

As you've described it. It seems to me that you will need to validate the values before assigning it to the new row of the dataset. Is that it?

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 4, 2009 at 12:52 PM

Hi,

The values for the dataset will be populated after which the validations should be fired on request.

Thanks,

Prasenna

 

Aug 7, 2009 at 9:05 AM

Hi,

Sorry for the late reply. As a result of my investigation for this, I think there is no direct way to validate a dataset object, since DataSet > DataTable > DataRow does not contain the property that you want to validate(properties that you can add your validator). But there are some work around that you can do. 1) You can validate first the values of which you will assign to the column of the DataRow. 2) Use a typed dataset and use VAB to validate it. Please see this thread about validating a typed dataset: http://entlib.codeplex.com/Thread/View.aspx?ThreadId=64736, you might want to consider this as your option.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com