Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a Datagridview and the Data Source is dtCustomer I just want to filter the content of grid view based on a search text. Itried the following code

DataTable dtSearch =  dtCustomer;
dtSearch.Select("cust_Name like '" + txtSearch.Text + "%'");
grvCustomer.DataSource = dtSearch;

But this is not working. If any body knows the solution please share.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
135 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try this:

dtSearch.DefaultView.RowFilter = "cust_Name like '" + txtSearch.Text + "%'";  

And check whatever there is space to be removed by triming the text.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...