Solved

2 Interactive Multiple Select Listbox in ASP.NET C#

Posted on 2007-11-23
6
3,576 Views
Last Modified: 2013-11-26
Hi,

I have the following table that I want to work with 2 multiple select listboxes.
Between two listboxes (inactive & active) are two buttons with opposite direction arrows
indicating where to place a selected item. The "active" column will be updated
each time an item is moved. For example if moved from inactive to active, "active" column will be updated to True. Also, I want to add an option to add a new area -- that would automatically added to the inactive listbox.

areaID      int      Unchecked
areaName      varchar(150)      Checked
weight      int      Checked
active      bit      Checked
createDate      datetime      Checked
updateDate      datetime      Checked  

To picture it out better, here's an illustration:
http://i62.photobucket.com/albums/h116/ikaruga7/multiselect.jpg

Can anyone provide me an example of how to do this in ASP.NET C#? Or perhaps just point me into the right direction. Is ajax needed to accomplish this? Or can this be done in purely C#?

Thanks in advance!
0
Comment
Question by:JaimeJegonia
6 Comments
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20339698
Ajax will be required, or else the other work around is using javascript to do this, but if you are using javascript to accomplish this then EnableEventValidation will have to be "false" at the top of the page in <@ Page %> tag.
The same thing i also had done in one of my web projects where i used my won Javascript stuff, as i didnt wanted a server trip to me made. Ajax does a server trip for adding or removing the data from data list.

I google you will find many javascript code example which you can then customize for yourself. Hope this helps you finalizing what you want to do. The major thing is Server Trip here.
0
 
LVL 20

Expert Comment

by:informaniac
ID: 20341840
There's a whole lot of things that you'll have to do.
Using Ajax would be better rather than writing Client Callback.

Since you are going to hit the server to make changes in the database table it is better to use ajax, to keep it simple as far as coding is concerned.

To start of with:
Place the listboxes in updatepanels.

Then write events on click of Add button and remove buttons.
Wherein u'll have to hit the database and update the column active.

To check which items are selected in listbox use this code

foreach(ListItem Li in listbox1.Items)
{
      if(Li.Selected)
          --do something
}
0
 

Author Comment

by:JaimeJegonia
ID: 20362735
Can anyone provide a code to show me how to accomplish this?
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 23

Accepted Solution

by:
Ashish Patel earned 500 total points
ID: 20363250
0
 

Author Closing Comment

by:JaimeJegonia
ID: 31410664
Thanks asvforce. The article is a good help. The sample code doesn't have the exact functionality I want but it's enough to get me started and arrive to expected result.
0
 
LVL 5

Expert Comment

by:Khalid Mehmood Awan
ID: 32260213
Link removed.... Asvforce, please update this knowledge base question....
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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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 …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

810 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