/// <summary> /// 省级选择完以后,联动带出城市 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ddlProvince_SelectedIndexChanged(object sender, EventArgs e) { string provId = ddlProvince.SelectedItem.Value; var disBll = new DistrictService(new DistrictRepository()); var disList = disBll.GetModelList("level=2 and upid=" + provId); if (disList != null) { ddlCity.DataTextField = "name"; ddlCity.DataValueField = "id"; ddlCity.DataSource = disList; ddlCity.DataBind(); } MessageBox.ResponseScript(this, "$(\"#txtUserName\").focus();"); }
/// <summary> /// 绑定省份 /// </summary> /// <param name="ddl"></param> public void BindDdlCity(DropDownList ddl) { var disBll = new DistrictService(new DistrictRepository()); IList<DistrictInfo> disList = disBll.GetModelList("level=2"); if (disList != null) { ddl.DataTextField = "name"; ddl.DataValueField = "id"; ddl.DataSource = disList; ddl.DataBind(); } }