Home > DeveloperSection > Forums > DataTable Select
Ashish Pandey

Total Post:128

Points:898
Posted on    September-05-2014 12:15 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 868  View(s)
Rate this:

How can I use Select method of a DataTable just to fetch UserNames starting with 'M'. Lets assume that UserNameTextBox has a string M

oDataTable.Select("UserName = '" + UserNameTextBox.Text + "'");

DataView oDataView = oDataTable.DefaultView;

oDataView.Sort = "UserName";

UserGridView.DataSource = oDataView;

UserGridView.DataBind();

and when I typed full name into textbox, which I am sure DataTable contains, it list everything not just what I typed. Can someone help me please?



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    September-05-2014 12:32 AM

Hi Ashish, 

try this:

DataView view = new DataView();

view.Table = oDataTable;

view.RowFilter = "UserName = '" + UserNameTextBox.Text + "'";

UserGridView.DataSource = view;

UserGridView.DataBind();


Don't want to miss updates? Please click the below button!

Follow MindStick