Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

2 Interactive Multiple Select Listbox in ASP.NET C#

Posted on 2007-11-23
6
Medium Priority
?
3,584 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 23

Accepted Solution

by:
Ashish Patel earned 1500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

876 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