Filter on Datagridview

  • Thread starter Thread starter shahoo
  • Start date Start date
S

shahoo

I have a datagridview on a form and It has two columns which are
comboboxes. The columns are use for showing name, lastname.

The columns are bound to a database table. I want to do this:
Suppose there are these information in the DB:
Name: LastName:
----------------------------------
John Smith
John Black
Alen Young
Now If the user selects John for name the last name would be showing
Smith and black. I mean I want to filter a column based

on another.
Can anyone please help?
 
I have a datagridview on a form and It has two columns which are
comboboxes. The columns are use for showing name, lastname.

The columns are bound to a database table. I want to do this:
Suppose there are these information in the DB:
Name: LastName:
----------------------------------
John Smith
John Black
Alen Young
Now If the user selects John for name the last name would be showing
Smith and black. I mean I want to filter a column based

on another.
Can anyone please help?

hope this helps

((DataTable)this.datagrid1.DataSource).DefaultView.RowFilter = "Name =
" + combobox.selectedtext

cheers
sunny
 
hope this helps
((DataTable)this.datagrid1.DataSource).DefaultView.RowFilter = "Name =
" + combobox.selectedtext

cheers
sunny

Thanks for the help. I solved it using something based on your way.
Now I have another problem.
I want the filtered row to show Distinct values. How can I do that?
 
Thanks for the help. I solved it using something based on your way.
Now I have another problem.
I want the filtered row to show Distinct values. How can I do that?

explain in detail please!!! give an example
 
explain in detail please!!! give an example

Fir example if there are these values in the table:
name: lastName: SSN
-----------------------------------------------------------
John Smith 1212
John Smith 112
Alen Young 232

and when the user selectes John for the name the combo box shows two
"Smith" values in it's dropdown list but I want to show only one
"Smith" not two.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top