第一次正常,
第二次点击前面的时,后面的dropdownlist显示的一组数据包含了前一次的
就是说在前一次的结果上添加了这次点击获得的数据
但是我只要这次点击获得的数据
第一个为不用代码绑定的
第二个为代码绑定
protected void DropDownListInstitute_SelectedIndexChanged(object sender, EventArgs e)
{
int instituteId = 0;
instituteId = Convert.ToInt32(DropDownListInstitute.SelectedValue);
if (instituteId > 0)
{
string sqlGetMajorList = "select MajorName,MajorId from T_majorinfo where InstituteId=" + instituteId + "";
DataSet dsMadjor = new DataSet();
QueryDataBase qdb = new QueryDataBase();
dsMadjor = qdb.Query(sqlGetMajorList); //我定义的一个返回dataset的方法
DropDownListMajor.DataSource = dsMadjor;
DropDownListMajor.DataTextField = "MajorName"; //绑定显示名称的字段,此处为专业名字
DropDownListMajor.DataValueField = "MajorId"; //绑定值的字段,此处为专业id
DropDownListMajor.DataBind();
}
}
“System.Web.UI.WebControls.DropDownList”不包含“Clear”的定义,并且找不到可接受类型为“System.Web.UI.WebControls.DropDownList”的第一个参数的扩展方法“Clear”(是否缺少 using 指令或程序集引用?)?????????
追答可能不是直接DropDownListMajor.Clear这样,或许是DropDownListMajor.items.Clear反正是把它数据源清空的方法。自己找吧...