By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,156 Members | 1,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,156 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Sep 5 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.
lance2001 wrote:
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
Sep 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.