Solved

Need example of dual list box, with database code

Posted on 2007-11-18
1
446 Views
Last Modified: 2008-02-01
Hello - Thanks, MacEx for your code snip for dual list boxes. Could you please elaborate on that, for use against a couple of database tables?

I'm trying to work up a page that allows a primary system user to specify the allowable divisions a regular staff-level user can access in a corporate financial system.

Given a lookup table like:

DivID / DivDesc
1  Accounting
2  Advertising
3  Engineering
4  HR
5  IT
etc...

...and a user control table like:
UserID / DivID
User01  1
User01  2
User02  2
User03  1
User03  4
User03  5
etc...

...I'd like to display the DivID's (that the user isn't already set up for) on the left-hand list box, and the DivID's they ARE set up for on the right-hand list box

I know what the queries (or views, or SP's) that pull the rowsource for the two list boxes needs to look like (I've done this before in MS Access/VBA). I just don't know how to code the list box events in VB.NET to pull the recordset's, and update them after an update.

And is that even the best way? Database updates after every listbox update, or pull the 2 rst's into arrays, do all the back & forth locally, until they click "Save", and then update the user control table? (this will be an intranet application)

Thanks; I hope this isn't over-reaching

Mark
0
Comment
Question by:mlagrange
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 20312353
With the ListBox control in ASP.NET there aren't a lot of events.  The basic one that you need is the SelectedIndexChanged.  In order for that to work properly, the page needs to post back.  This is usually accomplished by setting AutoPostBack = True for the ListBox.

Are the ListBox controls bound to a datasource, or populated with code?

Bob
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

825 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