<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web" %>
<head>
	<script language="C#" runat="server">
	public string SourceList;//来源ListBox
	public string TargetList;//目的ListBox
	void GetItem(Object sender, EventArgs e){
		ListBox SL=(ListBox)Page.FindControl(SourceList);
		ListBox TL=(ListBox)Page.FindControl(TargetList);
		foreach(ListItem CItem in SL.Items){//检查每一选项
			if(CItem.Selected==true){//若己选取
				TL.Items.Add(CItem.Text);//加入
			}
		}
		foreach(ListItem TItem in TL.Items){
			SL.Items.Remove(TItem);//删除
		}
	}
	void GetAllItem(Object sender, EventArgs e){
		ListBox SL=(ListBox)Page.FindControl(SourceList);
		ListBox TL=(ListBox)Page.FindControl(TargetList);
		foreach(ListItem CItem in SL.Items){
			TL.Items.Add(CItem.Text);
		}
		foreach(ListItem TItem in TL.Items){
			SL.Items.Remove(TItem);
		}
	}
	void RemoveItem(Object sender, EventArgs e){
		ListBox SL=(ListBox)Page.FindControl(SourceList);
		ListBox TL=(ListBox)Page.FindControl(TargetList);
		foreach(ListItem CItem in TL.Items){
			if(CItem.Selected==true){
				SL.Items.Add(CItem.Text);
			}
		}
		foreach(ListItem TItem in SL.Items){
			TL.Items.Remove(TItem);
		}
	}
	void RemoveAllItem(Object sender, EventArgs e){
		ListBox SL=(ListBox)Page.FindControl(SourceList);
		ListBox TL=(ListBox)Page.FindControl(TargetList);
		foreach(ListItem CItem in TL.Items){
			SL.Items.Add(CItem.Text);
		}
		foreach(ListItem TItem in SL.Items){
			TL.Items.Remove(TItem);
		}
	}
	</script>
</head>
<asp:button id="b1" Text=">" Font-size="10" Width="20" OnClick="GetItem" Runat="server" /><br>
<asp:button id="b2" Text=">>" Font-size="10" Width="20" OnClick="GetAllItem" Runat="server" /><br>
<asp:button id="b3" Text="<" Font-size="10" Width="20" OnClick="RemoveItem" Runat="server" /><br>
<asp:button id="b4" Text="<<" Font-size="10" Width="20" OnClick="RemoveAllItem" Runat="server" />

