DataTable Validation

I've a datatable which has many columns. The column value of Qty should be
Column value of TotalValue devided by SingleValue column. How to achive that validation? Please assist.
LVL 16
Easwaran ParamasivamAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
HugoHiaslConnect With a Mentor Commented:
You can use a foreach loop and loop through all the DataRows

Lets assume you cols in the table are 3,4,5

bool validationFailed = true;

foreach{DataRow row in dt.Rows) {

    if(row[5] != row[4] / row[3]) {
        validationFailed = false;
    }
}

Now you can give a validation message. If you need a dynamic column name resolition the loop through the dt.Columns array and get the indexes of the columns from there.
0
 
HugoHiaslConnect With a Mentor Commented:
You need to use Expression property of the column.

Find an example here:

http://www.codeproject.com/Articles/447249/Calculated-Columns-in-NET-DataTables-Csharp
0
 
Easwaran ParamasivamAuthor Commented:
I look for already available values in the table are correct or not. That should be entered by user. If not I need to throw validation message. Kindly suggest solution.
0
 
Easwaran ParamasivamAuthor Commented:
Thanks.
0
All Courses

From novice to tech pro — start learning today.