这是我们的代码:
<div>
<table style="width: 349px">
<tr>
<td class="style1">
<asp:ListBox ID="leftbox" runat="server" Height="114px" Width="212px"
SelectionMode="Multiple" AutoPostBack="True">
</asp:ListBox>
</td>
<td>
<asp:Button ID="Button1" runat="server" Text=">>" onclick="Button1_Click" /><br />
<asp:Button ID="Button2" runat="server" Text="<<" onclick="Button2_Click" />
</td>
<td>
<asp:ListBox ID="rightbox" runat="server" Height="117px" Width="231px"
SelectionMode="Multiple" AutoPostBack="True"></asp:ListBox>
</td>
</tr>
</table>
</div>
后面的代码是:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<string> list= GetNameList();
leftbox.DataSource = list;
leftbox.DataBind();
}
}
private static List<string> GetNameList()
{
List<string> list = new List<string>();
list.Add("keerthana");
list.Add("sirisha");
list.Add("anusha");
list.Add("Anuradha");
list.Add("Bhavani");
list.Add("divya");
list.Sort();
return list;
}
请告诉我如何在不使用服务器端代码的情况下从leftbox
到一个一个地添加两个或多个选定项(如下所示):rightbox
protected void Button1_Click(object sender, EventArgs e)
{
if (leftbox.SelectedIndex != -1)
{
rightbox.Items.Add(leftbox.SelectedItem.Text);
leftbox.Items.Remove(leftbox.SelectedItem.Text);
}
}
提前致谢...