Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Example of dual list box in ASP.NET

Posted on 2007-11-17
2
Medium Priority
?
2,654 Views
Last Modified: 2013-12-26
Hello - can anybody point me to a good sample of how to program a dual list box in ASP.NET 2.0, using VB?

(two list boxes, side by side; user double-clicks an item from the left-hand list box (or single-click's it, and clicks a button), and it drops off the left-hand list box and appears on the right-hand list box)

Thanks

Mark
0
Comment
Question by:mlagrange
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
McExp earned 2000 total points
ID: 20305839
I have created a sample page which demonstrates the key principals you are looking for.
<%@ Page Language="VB" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<script runat="server">
 
    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If (ListBox1.SelectedIndex >= 0) Then
            ListBox2.ClearSelection()
            Dim tmpItem As ListItem = ListBox1.SelectedItem
            ListBox1.Items.Remove(tmpItem)
            ListBox2.Items.Add(tmpItem)
        End If
    End Sub
 
    
    Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If (ListBox2.SelectedIndex >= 0) Then
            ListBox1.ClearSelection()
            Dim tmpItem As ListItem = ListBox2.SelectedItem
            ListBox2.Items.Remove(tmpItem)
            ListBox1.Items.Add(tmpItem)
        End If
    End Sub
</script>
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
    <tr>
    <td><asp:ListBox ID="ListBox1" runat="server">
        <asp:ListItem>Item A</asp:ListItem>
        <asp:ListItem>Item B</asp:ListItem>
        <asp:ListItem>Item C</asp:ListItem>
    </asp:ListBox></td>
    <td>
        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" >></asp:LinkButton><br />
        <asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click" ><</asp:LinkButton>
    </td>
    <td><asp:ListBox ID="ListBox2" runat="server"></asp:ListBox></td>
    </tr>
    </table>
    </div>
    </form>
</body>
</html>

Open in new window

0
 

Author Comment

by:mlagrange
ID: 20307958
Great - that's part of what I neeeded

I am going to accept this answer, and then ask a follow-up question; I would appreciate it if you would take a look at it.

Thanks

Mark

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

715 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