You don't populate your grid using a sql database. You populate your grid from a SQL Server database suing something else in between, e.g. a SqlDataAdapter
and a DataTable
.
A BindingSource
is supposed to be a one-stop shop for working with bound data so, while you don't have to use one, I would recommend doing so. Whether it can help you filter your data depends on what it's bound to. The BindingSource
doesn't actually do the work of filtering itself but rather passes the work on to the underlying IBindingListView
implementation if there is one. For instance, if the underlying data source is a DataTable
then the RowFilter
of its DefaultView
will be used. You could set the DefaultView.RowFilter
yourself.
If you want to do all the heavy lifting yourself then you could also search the grid yourself and then hide the rows that don't match. Those rows would still exist though, so you'd have to take that into account when using the data in code.