jQuery Ajax实现下拉框无刷新联动
2014-12-27 15:19
381 查看
HTML代码:
View Code
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Web.Mvc; using DAL; namespace Controllers.Backstage { /// <summary> /// 行政区划 /// </summary> public class AreaController : AdminBaseController { #region 构造函数及变量 private SQLiteHelper.SQLiteHelper sqliteHelper; private AreaDal areaDal; public AreaController() { sqliteHelper = new SQLiteHelper.SQLiteHelper(); areaDal = new AreaDal(); } #endregion #region 行政区划商圈级联选择页面 public ActionResult AreaSelect() { return PartialView(); } #endregion #region 获取全部省 public ActionResult GetProvinces() { DataTable dt = areaDal.GetProvincesAll(); StringBuilder sbHtml = new StringBuilder(); sbHtml.Append("<option value='-1'>==请选择==</option>"); foreach (DataRow dr in dt.Rows) { sbHtml.AppendFormat("<option value='{0}'>{1}</option>", dr["id"].ToString(), dr["name"].ToString()); } return Content(sbHtml.ToString()); } #endregion #region 根据省获取市 public ActionResult GetCities(string provinceId) { DataTable dt = areaDal.GetCities(provinceId); StringBuilder sbHtml = new StringBuilder(); sbHtml.Append("<option value='-1'>==请选择==</option>"); foreach (DataRow dr in dt.Rows) { sbHtml.AppendFormat("<option value='{0}'>{1}</option>", dr["id"].ToString(), dr["name"].ToString()); } return Content(sbHtml.ToString()); } #endregion #region 根据市获取区县 public ActionResult GetCounties(string cityId) { DataTable dt = areaDal.GetCounties(cityId); StringBuilder sbHtml = new StringBuilder(); sbHtml.Append("<option value='-1'>==请选择==</option>"); foreach (DataRow dr in dt.Rows) { sbHtml.AppendFormat("<option value='{0}'>{1}</option>", dr["id"].ToString(), dr["name"].ToString()); } return Content(sbHtml.ToString()); } #endregion #region 根据区县获取商圈 public ActionResult GetAreas(string countyId) { DataTable dt = areaDal.GetAreas(countyId); StringBuilder sbHtml = new StringBuilder(); sbHtml.Append("<option value='-1'>==请选择==</option>"); foreach (DataRow dr in dt.Rows) { sbHtml.AppendFormat("<option value='{0}'>{1}</option>", dr["id"].ToString(), dr["name"].ToString()); } return Content(sbHtml.ToString()); } #endregion } }
View Code
相关文章推荐
- jquery ajax实现下拉框三级无刷新联动,且保存保持选中值状态
- 基于jQuery Ajax实现下拉框无刷新联动
- jQuery Ajax实现下拉框无刷新联动
- jquery ajax实现下拉框三级无刷新联动,且保存保持选中值状态
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- XmlHttp实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- Atlas实现无刷新三级联动下拉框
- Ajax实现无刷新三联动下拉框
- Asp.Net XmlHttp实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- XmlHttp实现无刷新三联动下拉框
- 【Ajax实现无刷新三联动下拉框】
- Ajax实现无刷新三联动下拉框
- XmlHttp实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- 用Ajax.net实现的一个无刷新的多级联动下拉列表框