HOW CAN I VALIDATE IF THE COLUMN EXIST IN A DATAROW OBJECT?

Tanuj Kumar

Total Post:134

Points:940
Posted by  Tanuj Kumar
 1297  View(s)
Ratings:
Rate this:

private int EmploymentID { get; set; }

private void MapFields(DataRow row)

{

        if(row.HasError)

          EmploymentID = Convert.ToInt32(row["EmploymentID"].ToString());

}

The code shows that it validates if the DataRow object has error on its row but I want to validate if it ever exist. Is there an approach for the code rather using HasError method of DataRow?

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: How can I validate if the column exist in a DataRow object?

    You can also use this one statement

    row.Table.Columns.Contains("EmploymentID")

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!