• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

How do I bind a datagrid to a listbox selected item?

This is for VS2005.
I have one dataset created from a view created from 2 tables. I want the user to select a unit from the listbox and and then the datagridview will show what product is on that unit. I can do this by using a textbox.text property thru a button_click event where the user has to type in the actual unit name. I would like the listbox to show all the units when the form loads and the then the user to select the unit to show the list. I added the query, using @Unit as the variable in the query, FillByUnit.

CustomrerTableAdapter.FillByUnit(Dataset.Datatable, UnitNameListBox.SelectedItem)
This doesn't seem to work.

Thanks
0
grouchyfd
Asked:
grouchyfd
  • 3
  • 3
1 Solution
 
YZlatCommented:
use DataView
0
 
grouchyfdAuthor Commented:
I don't understand. This is not a property of my listbox. Could you please explain a little more in depth?

Thanks
0
 
YZlatCommented:
do you bind your DataGrid to a DataSet?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
grouchyfdAuthor Commented:
Yes I did.
0
 
YZlatCommented:
create a dataview based on your dataset:

Dim dv As New DataView(ds.Tables(0))

and then bind your datagrid to a dataview instead of a dataset.

Then you can ser RowFilter property of your dataview to whatever value user selects from  ListBox
0
 
grouchyfdAuthor Commented:
Because I'm using a view instead of a table I should use the dataview. That should work because I don't want the user to be able to edit anything.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now