按钮类型控件 选择类型控件
<body>
    <form id="form1" runat="server">
    <div class="style1">
    
        <br />
        <br />
        <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
            SelectionMode="Multiple">
        </asp:ListBox>
        <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
        <asp:Button ID="btnDel" runat="server" Text="移除" />
        <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
            Width="100px"></asp:ListBox>
            </div>
    </form>
</body><body>
    <form id="form1" runat="server">
    <div class="style1">
    
        <br />
        <br />
        <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
            SelectionMode="Multiple">
        </asp:ListBox>
        <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
        <asp:Button ID="btnDel" runat="server" Text="移除" />
        <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
            Width="100px"></asp:ListBox>
           
    </div>
    </form>
</body><body>
    <form id="form1" runat="server">
    <div class="style1">
    
        <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
            SelectionMode="Multiple">
        </asp:ListBox>
        <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
        <asp:Button ID="btnDel" runat="server" Text="移除" />
        <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
            Width="100px"></asp:ListBox>
           
    </div>
    </form>
</body><body>
    <form id="form1" runat="server">
    <div class="style1">
    
       
        <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
            SelectionMode="Multiple">
        </asp:ListBox>
        <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
        <asp:Button ID="btnDel" runat="server" Text="移除" />
        <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
            Width="100px"></asp:ListBox>
              </div>
    </form>
</body><body>
    <form id="form1" runat="server">
    <div class="style1">
    
        <asp:ListBox ID="lblist" runat="server" Height="115px" Width="104px" 
            SelectionMode="Multiple">
        </asp:ListBox>
        <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="添加" />
        <asp:Button ID="btnDel" runat="server" Text="移除" />
        <asp:ListBox ID="lbStat" runat="server" Height="116px" style="margin-top: 0px" 
            Width="100px"></asp:ListBox>
      
    </div>
    </form>
</body>
后台:
protected void Page_Load(object sender, EventArgs e) { AddUser(); } private void AddUser() { lblist.Items.Add("11"); lblist.Items.Add("22"); lblist.Items.Add("33"); lblist.Items.Add("44"); lblist.Items.Add("55"); lblist.Items.Add("66"); } protected void btnAdd_Click(object sender, EventArgs e) { for (int i = 0; i <lblist.Items.Count; i++) { if (lblist.Items[i].Selected) { ListItem li = lbStat.Items.FindByValue(lblist.Items[i].Text); if (li == null) { lbStat.Items.Add(lblist.Items[i].Text); } } } lblist.ClearSelection();//清除项目中的选中状态 }
protected void btnDel_Click(object sender, EventArgs e)
{
for (int i = 0; i < lbStat.Items.Count; i++)
{
if (lbStat.Items[i].Selected)
{
lbStat.Items.RemoveAt(i);
}
lblist.ClearSelection();
}
}
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号