asp.net中dropdownlist中绑定数据…

来源:互联网 发布:php属于编程语言 编辑:程序博客网 时间:2024/05/22 14:23
我用sqldatasource插件给dropdownlist绑定了数据源,
数据根据RadioButtonList中的选项来显示,代码如下
if (!IsPostBack)
                
               this.DropDownList1.Items.Clear();
               this.DropDownList1.AppendDataBoundItems = true;
               this.DropDownList1.Items.Add(new ListItem("=请选择=", "=请选择="));
               this.DropDownList1.DataValueField = "Kind2";
               this.DropDownList1.DataTextField = "Kind2";
               this.DropDownList1.DataSourceID = "SqlDataSource1";
               this.DropDownList1.DataBind();                       
          
       }
可问题是,每次改变RadioButtonList中的选项后,DropDownList中的数据项就会再次被加入,不同RadioButtonList对应的数据项都显示出来了,还刷新一次就加一次,导致出现重复的项,怎样在不删除“=请选择=”这个项的前提下,解决上面的问题。能给出代码最好
0 0