日期:2014-05-18  浏览次数:20496 次

两个ListBox中如何互相传值的
点击按钮 >> 就把ListBOx1 中的值传到 ListBOx2中了 
在点击 < < 就把ListBox2 中的值消除了. 
这东西谁有现成的代码. 不要JS 最好是后台代码
谢谢

------解决方案--------------------

我写了一个,你试一下吧, VS2005
HTML code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        &nbsp; &nbsp;&nbsp;
        <table style="width: 682px; height: 301px">
            <tr>
                <td style="width: 100px">
                    <asp:ListBox ID="ListBox1" runat="server" Height="170px" Width="308px">
                        <asp:ListItem>1</asp:ListItem>
                        <asp:ListItem>2</asp:ListItem>
                        <asp:ListItem>3</asp:ListItem>
                    </asp:ListBox></td>
                <td style="width: 100px">
                    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text=">>" Width="78px" /><br />
                    <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="<<" Width="79px" /></td>
                <td style="width: 100px">
                    <asp:ListBox ID="ListBox2" runat="server" Height="170px" Width="137px"></asp:ListBox></td>
            </tr>
        </table>
    
    </div>
    </form>
</body>
</html>