Solved

DataTable Validation

Posted on 2014-02-20
4
263 Views
Last Modified: 2014-02-20
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.
0
Comment
Question by:Easwaran Paramasivam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 12

Assisted Solution

by:HugoHiasl
HugoHiasl earned 300 total points
ID: 39873135
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
 
LVL 16

Author Comment

by:Easwaran Paramasivam
ID: 39873210
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
 
LVL 12

Accepted Solution

by:
HugoHiasl earned 300 total points
ID: 39873253
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
 
LVL 16

Author Closing Comment

by:Easwaran Paramasivam
ID: 39876002
Thanks.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question