zoukankan      html  css  js  c++  java
  • 省市区下拉框三级联动

    protected void Page_Load(object sender, EventArgs e) //加载
    {
    if (!IsPostBack)
    {
    FileSheng();
    FileShi();
    FileQu();
    }
    }

    public void FileSheng() //省
    {
    DropSheng.DataSource=_context.ChinaStates.Where(p => p.ParentAreaCode == "0001");
    DropSheng.DataTextField = "AreaName";
    DropSheng.DataValueField = "AreaCode";

    DropSheng.DataBind();
    }

    public void FileShi() //市
    {
    string sheng = DropSheng.SelectedValue.ToString();
    DropShi.DataSource = _context.ChinaStates.Where(p => p.ParentAreaCode == sheng);
    DropShi.DataTextField = "AreaName";
    DropShi.DataValueField = "AreaCode";

    DropShi.DataBind();
    }

    public void FileQu() //区
    {
    string shi = DropShi.SelectedValue.ToString();
    DropQu.DataSource = _context.ChinaStates.Where(p => p.ParentAreaCode == shi);
    DropQu.DataTextField = "AreaName";
    DropQu.DataValueField = "AreaCode";

    DropQu.DataBind();
    }


    AutoPostBack=True; //属性修改
    protected void DropSheng_SelectedIndexChanged(object sender, EventArgs e)
    {
    FileShi();
    }

    AutoPostBack=True; //属性修改
    protected void DropShi_SelectedIndexChanged(object sender, EventArgs e)
    {
    FileQu();
    }

  • 相关阅读:
    TLPI读书笔记第15章-文件属性2
    TLPI读书笔记第15章-文件属性1
    Java异常及错误
    10055
    4月。
    JavaScript三种方法获取地址栏参数的方法
    页面预加载loading动画,再载入内容
    什么是可串行化MVCC
    简化版扫雷详细解
    论unity中UI工具与GUI函数
  • 原文地址:https://www.cnblogs.com/duan594939295/p/5065095.html
Copyright © 2011-2022 走看看