Solved

2 Interactive Multiple Select Listbox in ASP.NET C#

Posted on 2007-11-23
6
3,573 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
Comment Utility
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
Comment Utility
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
Comment Utility
Can anyone provide a code to show me how to accomplish this?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 23

Accepted Solution

by:
Ashish Patel earned 500 total points
Comment Utility
0
 

Author Closing Comment

by:JaimeJegonia
Comment Utility
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
Comment Utility
Link removed.... Asvforce, please update this knowledge base question....
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now