---
title: "DataTable Select"  
description: "DataTable Select"  
author: "Anonymous User"  
published: 2014-09-05  
updated: 2014-09-05  
canonical: https://www.mindstick.com/forum/2249/datatable-select  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# DataTable Select

How can I use [Select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) [method](https://www.mindstick.com/forum/166/webservice-method) of a [DataTable](https://www.mindstick.com/blog/195/datatable-in-ado-dot-net) just to [fetch](https://www.mindstick.com/forum/156159/what-is-google-fetch) UserNames [starting](https://www.mindstick.com/blog/12024/things-you-need-to-know-when-starting-your-own-business) with 'M'. Lets assume that UserNameTextBox has a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) M

oDataTable.Select("[UserName](https://www.mindstick.com/forum/12798/there-is-no-viewdata-item-of-type-ienumerable-selectlistitem-that-has-the-key-username) = '" + UserNameTextBox.Text + "'");

[DataView](https://www.mindstick.com/blog/151/dataview-in-ado-dot-net) oDataView = oDataTable.DefaultView;

oDataView.Sort = "UserName";

UserGridView.DataSource = oDataView;

UserGridView.DataBind();

and when I typed [full name](https://answers.mindstick.com/qa/110831/what-is-queen-elizabeth-ii-s-full-name) into [textbox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview), which I am sure DataTable contains, it list everything not just what I typed. Can someone help me please?

## Replies

### Reply by Sumit Kesarwani

Hi Ashish, \
try this:

```
DataView view = new DataView();view.Table = oDataTable;view.RowFilter = "UserName = '" +
UserNameTextBox.Text + "'";UserGridView.DataSource = view;UserGridView.DataBind();
```


---

Original Source: https://www.mindstick.com/forum/2249/datatable-select

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
