---
title: "How to Get a Specific Column Value from a DataTable?"  
description: "How to Get a Specific Column Value from a DataTable?"  
author: "Tarun Kumar"  
published: 2016-02-24  
updated: 2016-02-24  
canonical: https://www.mindstick.com/forum/34001/how-to-get-a-specific-column-value-from-a-datatable  
category: "c#"  
tags: ["c#", "ado.net", ".net", "winforms"]  
reading_time: 1 minute  

---

# How to Get a Specific Column Value from a DataTable?

I want to [fetch](https://www.mindstick.com/forum/156159/what-is-google-fetch) a certain [column value](https://www.mindstick.com/forum/161178/how-to-delete-duplicate-rows-based-on-single-column-value-in-mssql) based on the [user input](https://www.mindstick.com/forum/159624/setting-an-enum-from-user-input) lets [say](https://answers.mindstick.com/qa/116645/a1-wreckers-reviews-what-do-customers-say) the [datatable](https://www.mindstick.com/blog/195/datatable-in-ado-dot-net) has two columns ID and CountryName.

I need to find ID in the datatable based on the user input [country](https://yourviews.mindstick.com/view/85543/do-you-think-that-french-will-be-islamic-country) name.

please help\

## Replies

### Reply by Uttam Misra

Here you go:\
\

```
string Name = "MARK";
DataTable dt = new DataTable();
int ID= (from DataRow dr in dt.Rows
              where (string)dr["Name"] == Name
              select (int)dr["ID"]).FirstOrDefault();
```

\


---

Original Source: https://www.mindstick.com/forum/34001/how-to-get-a-specific-column-value-from-a-datatable

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
