/// <summary> /// 加载一级信息 /// </summary> private void LoadOneInfo() { DataSet ds = AreaInfoService.GetList("parentId = 0"); if (ds.Tables[0].Rows.Count > 0) { ddlOne.Items.Clear(); ddlOne.DataSource = ds; ddlOne.DataTextField = "areaName"; ddlOne.DataValueField = "id"; ddlOne.DataBind(); //this.ddlProvince.SelectedValue = "1"; ddlProvince.Items.Clear(); ddlProvince.DataSource = ds; ddlProvince.DataTextField = "areaName"; ddlProvince.DataValueField = "id"; ddlProvince.DataBind(); } ddlOne.Items.Insert(0, new ListItem("请选择省级分类", "0")); ddlProvince.Items.Insert(0, new ListItem("请选择省级分类", "0")); //加载热门信息 LoadHotInfo(); }
/// <summary> /// 绑定信息 /// </summary> private void BindData() { DataSet ds = AreaInfoService.GetList("parentId = 0"); if (ds.Tables[0].Rows.Count > 0) { location_p.DataSource = ds; location_p.DataTextField = "areaName"; location_p.DataValueField = "id"; location_p.DataBind(); } location_p.Items.Insert(0, new ListItem("请选择", "0")); location_c.Items.Insert(0, new ListItem("请选择", "0")); location_a.Items.Insert(0, new ListItem("请选择", "0")); UserAddress item = UserAddressService.GetModel(id); if (item != null) { ViewState["labelname"] = item.addressDetail; ViewState["address"] = item.address; ViewState["telephone"] = item.tel; ViewState["mobile"] = item.mobile; ViewState["name"] = item.relName; location_p.SelectedValue = item.qq; location_c.Items.Clear(); ds = AreaInfoService.GetList("parentId = " + location_p.SelectedValue); if (ds.Tables[0].Rows.Count > 0) { location_c.DataSource = ds; location_c.DataTextField = "areaName"; location_c.DataValueField = "id"; location_c.DataBind(); } location_c.Items.Insert(0, new ListItem("请选择", "0")); location_c.SelectedValue = item.weixin; location_a.Items.Clear(); ds = AreaInfoService.GetList("parentId = " + location_c.SelectedValue); if (ds.Tables[0].Rows.Count > 0) { location_a.DataSource = ds; location_a.DataTextField = "areaName"; location_a.DataValueField = "id"; location_a.DataBind(); } location_a.Items.Insert(0, new ListItem("请选择", "0")); location_a.SelectedValue = item.zipcode; } }
protected void location_c_SelectedIndexChanged(object sender, EventArgs e) { location_a.Items.Clear(); DataSet ds = AreaInfoService.GetList("parentId = " + location_c.SelectedValue); if (ds.Tables[0].Rows.Count > 0) { location_a.DataSource = ds; location_a.DataTextField = "areaName"; location_a.DataValueField = "id"; location_a.DataBind(); } location_a.Items.Insert(0, new ListItem("请选择", "0")); }
private void LoadHotInfo() { StringBuilder sb = new StringBuilder(); DataSet ds = AreaInfoService.GetList("status = " + 1); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { sb.Append("<label class=\"preview\"> " + dr["areaName"] + "</label>"); } } ViewState["hotInfo"] = sb.ToString(); }
/// <summary> /// 一级信息加载 /// </summary> /// <returns></returns> protected string GetOneInfo() { StringBuilder sb = new StringBuilder(); DataSet ds = AreaInfoService.GetList("parentId = 0"); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { sb.Append("<label class=\"preview\"><input type=\"radio\" id='one" + dr["id"] + "' name='one' onclick=\"getOneInfo(" + dr["id"] + ",'" + dr["areaName"] + "','" + dr["charIndex"] + "',this);\" />" + dr["areaName"] + "</label>"); } } return(sb.ToString()); }
/// <summary> /// 市信息加载 /// </summary> /// <returns></returns> private void GetTwo(string pid) { StringBuilder sb = new StringBuilder(); if (pid != "0") { DataSet ds = AreaInfoService.GetList("parentId = " + pid); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { sb.Append("<label class=\"preview\"><input type=\"radio\" id='city" + dr["id"] + "' name='city' onclick=\"getCityInfo(" + dr["id"] + ",'" + dr["areaName"] + "','" + dr["charIndex"] + "',this);\" />" + dr["areaName"] + "</label>"); } } } ViewState["twoInfo"] = sb.ToString(); }
/// <summary> /// 省级分类下拉事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ddlProvince_SelectedIndexChanged(object sender, EventArgs e) { string pid = ddlProvince.SelectedValue; if (pid != "0") { ddlCity.Items.Clear(); DataSet ds = AreaInfoService.GetList("parentId = " + pid); if (ds.Tables[0].Rows.Count > 0) { ddlCity.DataSource = ds; ddlCity.DataTextField = "areaName"; ddlCity.DataValueField = "id"; ddlCity.DataBind(); } ddlCity.Items.Insert(0, new ListItem("请选择", "0")); } }