Me.DropDownList1.Items.RemoveAt(序号)
序号是唯一的
Me.DropDownList1.Items.Remove(某项的内容)
某项的内容可能不是唯一的吧?

解决方案 »

  1.   

    某项的内容可是唯一的啊!
    就算不是唯一的,DropDownList1.Items.Remove(string)既然有这种属性,它应该移去所有内容为“某项的内容”的项啊。
      

  2.   

    可以删除.我的测试代码:
    <%@ Page language="C#" runat="server" debug=true%>
    <html>
    <head>
    <script language="C#" runat="Server">
    void aa()
    {
    wz1.Items.Clear();
    wz2.Items.Clear();
    int k;
    int i;
    for (i=0;i<3;i++)
    {
    k=i+1;
    ListItem item1=new ListItem();
    ListItem item2=new ListItem();
    item1.Text="WZ00"+k;
    item1.Value="WZ00"+k; item2.Text="WZ00"+k;
    item2.Value="WZ00"+k; wz1.Items.Add(item1);
    wz2.Items.Add(item2);

    }
    } public void Page_Load(object sender, EventArgs e) {
    aa();
    int i;
    for (i=0;i<2;i++)
    {
    if (i==0)
    {
    wz1.Items[wz1.SelectedIndex].Selected=false;
    wz1.Items[0].Selected=true;
    }
    if (i==1)
    {
    wz2.Items[wz2.SelectedIndex].Selected=false;
    wz2.Items[1].Selected=true;
    }
    }
    }
    void click(object obj, EventArgs e) {
    wz1.Items.RemoveAt(0);
    wz2.Items.Remove("WZ002");
    }
    </script>
    </head>
    <body>
    <form runat="server">
    <asp:DropDownList id=wz1 runat=server></asp:DropDownList>
    <asp:DropDownList id=wz2 runat=server></asp:DropDownList>
    <br>
    <asp:button id=bu Text="Remove" Onclick=click runat=server/>
    </form>
    </body>
    </html>
      

  3.   

    非动态绑定的DropDownList也可以.
    譬如:
    <%@ Import namespace="System.Drawing"%>
    <%@ Page language="C#" debug="True"%><html>
     <head>
      <script language="C#" runat="server">
        void Button_Click(Object sender,EventArgs e)
        {
    DropDownList1.Items.RemoveAt(1);
        }
    void remove(object obj, EventArgs e) {
    DropDownList2.Items.Remove("color2");
    }
     </script>
     </head>
     <body>
       <form runat="server">
       <h4><font face="verdana">DropDownList </h4></font>  
       <asp:DropDownList id="DropDownList1"  BorderColor="Lightgreen" runat="server">
            <asp:ListItem>color1</asp:ListItem>
            <asp:ListItem>color2</asp:ListItem>
            <asp:ListItem>color3</asp:ListItem>
            <asp:ListItem>color4</asp:ListItem>
       </asp:DropDownList>
       <asp:DropDownList id="DropDownList2"  BorderColor="Lightgreen" runat="server">
            <asp:ListItem>color1</asp:ListItem>
            <asp:ListItem>color2</asp:ListItem>
            <asp:ListItem>color3</asp:ListItem>
            <asp:ListItem>color4</asp:ListItem>
       </asp:DropDownList>   
       <br><br>
       <asp:Button id="Button1" Text="RemoveAt" OnClick="Button_Click" runat="server"/>
       <asp:Button id="bu" Text="Remove" OnClick="remove" runat="server"/>   </form>
      </body>
    </html>  也可以删除的啊
      

  4.   

    Me.DropDownList1.Items.Remove(某项的内容)
    你说的“某项的内容”是指什么?是ListItem的Value值还是Text值?
      

  5.   

    DropDownList1.Items.Remove有两种重载形式:
    DropDownList1.Items.Remove(System.Web.UI.WebControls.ListItem Item);
    DropDownList1.Items.Remove(string Item);
    你看看事不是参数指定的不正确!
      

  6.   

    to webdiyer(webdiyer) :是Text值