?
Solved

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

Posted on 2006-07-10
6
Medium Priority
?
202 Views
Last Modified: 2010-04-23
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
Comment
Question by:grouchyfd
  • 3
  • 3
6 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 17076359
use DataView
0
 

Author Comment

by:grouchyfd
ID: 17076588
I don't understand. This is not a property of my listbox. Could you please explain a little more in depth?

Thanks
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17076627
do you bind your DataGrid to a DataSet?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:grouchyfd
ID: 17076796
Yes I did.
0
 
LVL 35

Accepted Solution

by:
YZlat earned 2000 total points
ID: 17076875
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
 

Author Comment

by:grouchyfd
ID: 17076915
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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month16 days, 2 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question