0

i have datagrid view which uses dataset..

i would like to filter my datagridview by idCardNumber (getting it from the textbox1)

how can i do so? could u explain pls?

3
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by xanawa
0

Hi
i believe you can do this.

DataView MyDataView = MyDataSet.Tables[0].DefaultView;

MyDataView.RowFilter = "IdCardNumber = "+Convert.ToInt32(textbox1.Text)+"";
MyDataGrid.DataSource = MyDataView;
MyDataGrid.DataBind();
0

This line helps me filtering a DataGridView:

My DataGridView.DataSource = <name>BindingSource
this.<name>BindingSource.Filter = String.Format("<columnname> LIKE '%{0}%'", TextBoxFilter.Text);

The DataGridView and BindingSource were generated automatically.

If you do not use the bindingsource, you can apply a filter by changing the DefaultView of the table which is shown in the grid.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.