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();
    }

  • 相关阅读:
    将webcam设置为网站favicon
    IIS简单的反向代理设置
    在Heroku上免费部署ASP.NET Core(使用Docker和CircleCI)
    ModelBiner不验证某个属性
    大项目小细节---切换选项卡后的操作
    测试理论
    测试理论
    测试理论
    Chrome
    Docker
  • 原文地址:https://www.cnblogs.com/duan594939295/p/5065095.html
Copyright © 2011-2022 走看看