我是个AJAX的三级联动 的省,市、县下拉框。现在我想让它默认显示的是从数据库中读取到的值,而不是默认的第一值。
public void bindclass()
{
this.DropDownList1.DataSource = AjaxMethod.GetProvinceList(); this.DropDownList1.DataTextField = "PROVINCESNAME";
this.DropDownList1.DataValueField = "CODE";
this.DropDownList1.DataBind();
this.DropDownList1.Items.Insert(0, new ListItem("请选择省", "0"));
model = bll.GetModel(int.Parse(Request.Params["id"]));
this.DropDownList1.SelectedValue = model.o_Province;//默认显示数据库中的值 this.DropDownList1.Attributes.Add("onchange", "cityResult();");
this.DropDownList2.Attributes.Add("onchange", "areaResult();"); this.Introdry_1.DataSource = AjaxMethod.GetIntrod_1();
Introdry_1.DataTextField = "GB_SortName";
Introdry_1.DataValueField = "Id";
Introdry_1.DataBind();
this.Introdry_1.Items.Insert(0, new ListItem("请选择行业", "0"));
Introdry_1.Attributes.Add("onclick", "Introd_2();"); }
这是我的代码, this.DropDownList1.SelectedValue = model.o_Province;//默认显示数据库中的值这样写的不起作用、
public void bindclass()
{
this.DropDownList1.DataSource = AjaxMethod.GetProvinceList(); this.DropDownList1.DataTextField = "PROVINCESNAME";
this.DropDownList1.DataValueField = "CODE";
this.DropDownList1.DataBind();
this.DropDownList1.Items.Insert(0, new ListItem("请选择省", "0"));
model = bll.GetModel(int.Parse(Request.Params["id"]));
this.DropDownList1.SelectedValue = model.o_Province;//默认显示数据库中的值 this.DropDownList1.Attributes.Add("onchange", "cityResult();");
this.DropDownList2.Attributes.Add("onchange", "areaResult();"); this.Introdry_1.DataSource = AjaxMethod.GetIntrod_1();
Introdry_1.DataTextField = "GB_SortName";
Introdry_1.DataValueField = "Id";
Introdry_1.DataBind();
this.Introdry_1.Items.Insert(0, new ListItem("请选择行业", "0"));
Introdry_1.Attributes.Add("onclick", "Introd_2();"); }
这是我的代码, this.DropDownList1.SelectedValue = model.o_Province;//默认显示数据库中的值这样写的不起作用、
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货