DataTable dt = new DataTable();
DAL.Exec.Exec_YSBiz10_Dim_Area exec_YSBiz10_Dim_Area = new DAL.Exec.Exec_YSBiz10_Dim_Area();
dt= exec_YSBiz10_Dim_Area.tb();
this.DropDownList1.DataSource = dt;
this.DropDownList1.DataTextField = "AreaName";
this.DropDownList1.DataValueField = "AreaID";
this.DropDownList1.DataBind();
this.DropDownList1.Items.Insert(0,"所有省份");给下拉框的值附一个初始值:
this.DropDownList1.SelectedItem.Text = "";
代码报错请问怎么做啊
DAL.Exec.Exec_YSBiz10_Dim_Area exec_YSBiz10_Dim_Area = new DAL.Exec.Exec_YSBiz10_Dim_Area();
dt= exec_YSBiz10_Dim_Area.tb();
this.DropDownList1.DataSource = dt;
this.DropDownList1.DataTextField = "AreaName";
this.DropDownList1.DataValueField = "AreaID";
this.DropDownList1.DataBind();
this.DropDownList1.Items.Insert(0,"所有省份");给下拉框的值附一个初始值:
this.DropDownList1.SelectedItem.Text = "";
代码报错请问怎么做啊
DropDownList1.SelectedValue="";
city = this.DropDownList1.SelectedItem.Text.ToString();
报错信息,说未将对象引用,请问怎么回事
试试:
city = this.DropDownList1.SelectedItem.Text;
DropDownList1.SelectedIndex=-1;//先去除已选项,一个DropDownList不能有两个已选项
DropDownList1.SelectedValue="";//
DropDownList1.DataTextField = "cl_name";
DropDownList1.DataValueField = "cl_parent";
DropDownList1.DataBind();DropDownList1.Items.Insert(0, "所有内容");
this.DropDownList1.SelectedItem.Text = ""; //这个好像没什么意义吧,只会把你的后面添加的 所有省份 这项直接变成""我试了下,代码这样写没有错,只不过它会把你选择的项的TEXT值设成空了.
应该还是你前面绑定代码的问题
你设断点踊跃调试下!