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.
Try this:
dtSearch.DefaultView.RowFilter = "cust_Name like '" + txtSearch.Text + "%'";
And check whatever there is space to be removed by triming the text.
Or Try this;
dataGridView.Datasource = datatable.Select("....").CopyToDataTable()
You can do something like this.
DataView dv1 = dtDefault.DefaultView;
dv1.RowFilter = "CusGroupId=1 and CustomerCode LIKE '"+txtCustomer.Text +"%'";
DataTable dt=dv1.ToTable();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With