VB.NET 2005 EE: Best method of dependent listbox filling from database?

L

lance2001

Hi,

After viewing the entire Visual Basic 2005 Express Edition for
Beginners video series, I have begun building a database driven
application that will make use of listbox1 (multi-select) determining
what shows up in listbox2 (multi_select), which determines listbox3,
etc.... Each each listbox is populated from a different table in the
same database.

The databinding examples given in the video seem to leave no way for a
"Select ALL" and/or "None" option being added to the listbox without
adding those items to the database itself. In order to best accomplish
this, must I forget about using databinding and just code directly with
SQLCommand and SQLDataReader objects and write code to loop through the
listbox.SelectedObjectCollection to determine what has been selected
and construct a SQL statement?

I tried using the listbox.items.add method with databinding but that
didn't go well. When I did the same thing to add "None" to the top of
the listbox and then loop through my table items it seemed to work.
Would a grid object work better for this with some kind of hidden
value serving as the index rather than trying to use the listbox
control?

With the listbox control, is there a way to use a value in the database
as the index for determining what is selected in the control rather
than using the 0,1,2,,, position index built into it?

Any pointers in the right direction or urls with examples are much
appreciated. With all of the cool features built into VB.NET 2005
Express Edition, I'm hoping I don't have to go back to building SQL
statements just to add a "None" option to a listbox and throw
databinding out the window. Thanks!

Lance
 
A

aaron.kempf

so keep it in a database with value -1.

-1, 'All'

when you don't want it to show up; you select > 0 for example (with 0
being NONE)


it's not rocket science to say the least.
in Access Data Projects it would take me about 3 seconds.
 

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

Top