---
title: "How can I validate if the column exist in a DataRow object?"  
description: "How can I validate if the column exist in a DataRow object?"  
author: "Anonymous User"  
published: 2014-09-02  
updated: 2014-09-03  
canonical: https://www.mindstick.com/forum/2240/how-can-i-validate-if-the-column-exist-in-a-datarow-object  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# How can I validate if the column exist in a DataRow object?

```
private int EmploymentID { get; set; }private void MapFields(DataRow row){       
if(row.HasError)          EmploymentID
= Convert.ToInt32(row["EmploymentID"].ToString());}
```

The [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) [shows](https://yourviews.mindstick.com/view/81380/new-york-violent-shooting-shows-people-are-not-safe-in-night-life) that it validates if the [DataRow object](https://www.mindstick.com/forum/12691/get-datarow-object-from-selected-row-in-gridview) has [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing) on its [row](https://www.mindstick.com/forum/1212/this-row-already-belongs-to-this-table) but I want to [validate if](https://www.mindstick.com/forum/12949/how-to-validate-if-a-datetime-field-is-not-null-empty) it ever exist. Is there an [approach](https://www.mindstick.com/interview/985/what-are-the-approaches-that-you-will-follow-for-making-a-program-very-efficient) for the code rather using HasError [method](https://www.mindstick.com/forum/166/webservice-method) of DataRow?

## Replies

### Reply by Sumit Kesarwani

You can also use this one statement

row.Table.Columns.Contains("EmploymentID")


---

Original Source: https://www.mindstick.com/forum/2240/how-can-i-validate-if-the-column-exist-in-a-datarow-object

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
