日期:2014-05-18  浏览次数:20489 次

DropDownList绑定数据的问题?谢谢
错误:
System.ArgumentOutOfRangeException:   指定的参数已超出有效值的范围。参数名:   value

数据返回的是DataSet
以下绑定代码
this.dl_stair_params_name.DataSource   =   bll.GetList(strWhere);
this.dl_stair_params_name.DataTextField   =   "Parameter_Name ";
this.dl_stair_params_name.DataTextField   =   "Parameter_Name ";
this.dl_stair_params_name.DataBind();

如何解决问题??谢谢

------解决方案--------------------
this.dl_stair_params_name.DataTextField = "Parameter_Name ";
this.dl_stair_params_name.DataTextField = "Parameter_Name ";

老兄,第二个应该是DataValueField吧?
------解决方案--------------------
是啊 应该是DataValueField吧
------解决方案--------------------
兄弟,是不是没有数据啊。
------解决方案--------------------
绑定前
this.dl_stair_params_name.selectedindex = -1;

------解决方案--------------------
感觉 你是不是没清空参数啊 scmd.Parameters.Clear();
------解决方案--------------------
这样试试:
DataSet st = bll.GetList(strWhere);
this.dl_stair_params_name.DataSource = st.Tables[0].DefaultView;
this.dl_stair_params_name.DataTextField = "Parameter_Name ";
this.dl_stair_params_name.DataTextField = "Parameter_Name ";
this.dl_stair_params_name.DataBind();
------解决方案--------------------
把其中的一个DataTextField 改为DataValueField
可能是你在绑定具体的值时发生了错误
------解决方案--------------------
DataTable dt = bll.GetList(strWhere);
this.dl_stair_params_name.DataSource = st.Tables[0].DefaultView;
this.dl_stair_params_name.DataTextField = "Parameter_Name ";
this.dl_stair_params_name.DataValueField = "Parameter_id ";
this.dl_stair_params_name.DataBind();

------解决方案--------------------
DataTable dt = bll.GetList(strWhere);
this.dl_stair_params_name.DataSource = dt.DefaultView;
this.dl_stair_params_name.DataTextField = "Parameter_Name ";
this.dl_stair_params_name.DataValueField = "Parameter_id ";
this.dl_stair_params_name.DataBind();