关于DropDownList显示数据的问题
我在后台这样给DropdownList绑定数据
         this.dropMF1.Items.Clear();//先清空
        Tb_companyHelper chelper = new Tb_companyHelper();
        Tb_companyInfo cInfo = new Tb_companyInfo();
        this.dropMF1.DataSource = chelper.GetAllList(cInfo);        
        this.dropMF1.DataBind();
        this.dropMF1.Items.Insert(0, new ListItem("--请选择--", "--请选择--"));
我一直都是用这个方法,但是现在出现了个问题,“--请选择--”在页面显示了一次,但是数据库提取的数据在页面上
全部显示了2遍?我断点进去一看,DataSource 的count数据只有3条,页面却有6条数据。不解何故
页面代码是这样的:
        <asp:DropDownList ID="dropMF1" runat="server"
            DataTextField="u_Name"  
            DataValueField="u_Name"
            AppendDataBoundItems="True">
        </asp:DropDownList>
哪位大神帮帮忙解决一下,感激
------解决方案--------------------从你的代码看不出问题所在
------解决方案--------------------  <asp:DropDownList ID="dropMF1" runat="server"
 DataTextField="u_Name"  
 DataValueField="u_Name"
 AppendDataBoundItems="True">
 </asp:DropDownList>
红色部分去掉
估计是第二次绑定时,将原先的数据又追加到后面了。