Solved

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

Posted on 2006-07-10
6
193 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

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

Accepted Solution

by:
YZlat earned 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

772 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