错哪了?在线!!!!
<% @ Page language="C#"%>
<script language="C#" runat="server">
public void ToRigtList(object sender,EventArgs e)
{
for(int i=0; i<lbox1.Items.Count;i++)
{
ListItem item=lbox1.Items[i];
if(item.Selected)
{
lbox2.Items.Add(item);
lbox1.Items.Remove(item);
}
}
}
public void ToLeftList(object sender,EventArgs e)
{
for(int i=0; i<lbox2.Items.Count;i++)
ListItem item=lbox2.Items[i];
if(item.Selected)
{
lbox1.Items.Add(item);
lbox2.Items.Remove(item);
}
}
</script>
<html>
<head>
<title><title>
</head>
<body>
<b>ListBox演示</b>
<hr>
<form runat="server">
<table>
<tr>
<td>
<b>ListBox容器1:</b><br>
<asp:ListBox id="lbox1" Rows=5 SelectionMode="Multiple" runat="server">
<asp:ListItem>天天</asp:ListItem>
<asp:ListItem>天健</asp:ListItem>
<asp:ListItem>皇帝</asp:ListItem>
<asp:ListItem>皇后</asp:ListItem>
<asp:ListItem>靖靖</asp:ListItem>
</asp:ListBox>
</td>
<td>
<asp:Button id="ToRight" Text="-->" OnClick="ToRightList" runat="server"/>
<asp:Button id="ToLeft" Text="<--" OnClick="ToLeftList" runat="server"/>
</td>
<td>
<b>ListBox容器2:</b><br>
<asp:ListBox id="lbox2" Rows=5 SelectionMode="Multiple" runat="server"/>
</td>
</form>
</body>
</html>