Sorting data using BindingSource C#.Net

03/05/2007 - 11:07 por Peter Matogo | Informe spam
Hello people,

I have a problem that has been nagging me for quite some time now...let
me give you a brief description:

I have on my form 4 controls:
-An ordinary TextBox
-A DataGridView
-A DataSet
-and a BindingSource
the DataSource for the DataGridView is the BindingSource control. The
data source for the BindingSource is the DataSet.
So when the user enters some text in the TextBox the DataGridView is
automatically filtered. I used the following line of code to apply the
filter:
productsBindingSource.Filter = string.Format("Name like '%{0}%'",
txtFilter.Text);

that works fine

now the problem comes in when i try to get the index of the filtered
data in the DataGridView.For example, the first item in the filtered
text picks the first item in the original set.
So how can i update or refresh the data after I apply the filter??
Any help will be greatly appreciated

*** Sent via Developersdex http://www.developersdex.com ***
 

Leer las respuestas

#1 ANT1
03/05/2007 - 11:34 | Informe spam
On 3 mayo, 11:07, Peter Matogo wrote:
Hello people,

I have a problem that has been nagging me for quite some time now...let
me give you a brief description:

I have on my form 4 controls:
-An ordinary TextBox
-A DataGridView
-A DataSet
-and a BindingSource
the DataSource for the DataGridView is the BindingSource control. The
data source for the BindingSource is the DataSet.
So when the user enters some text in the TextBox the DataGridView is
automatically filtered. I used the following line of code to apply the
filter:
productsBindingSource.Filter = string.Format("Name like '%{0}%'",
txtFilter.Text);

that works fine

now the problem comes in when i try to get the index of the filtered
data in the DataGridView.For example, the first item in the filtered
text picks the first item in the original set.
So how can i update or refresh the data after I apply the filter??
Any help will be greatly appreciated

*** Sent via Developersdexhttp://www.developersdex.com***



If datagridview.refresh() doesn't work try to unbind de source and
rebind it.

datagridview.datasource = null;
datagridview.datasource = yourdatabindingsource;

Preguntas similares