• 省市县三级联动(webFrom...DropdownList)


    编辑页面

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        </div>
            <asp:DropDownList ID="DropDownList1" runat="server" Width="100px" AutoPostBack="True" Height="50px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" style="margin-bottom: 0px" >
            </asp:DropDownList>
            <asp:DropDownList ID="DropDownList2" runat="server" Width="100px" AutoPostBack="True" Height="50px" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged">
            </asp:DropDownList>
            <asp:DropDownList ID="DropDownList3" runat="server" Width="100px" AutoPostBack="True" Height="50px">
            </asp:DropDownList>
        </form>
    </body>
    </html>

    编辑cs

    public partial class Test2 : System.Web.UI.Page
    {
        public DataClassesDataContext context;
    
        protected void Page_Load(object sender, EventArgs e)
        {
            context = new DataClassesDataContext();
            if(!IsPostBack)
            {
                databind("0001");
                datashibind("11");
                dataxianbind("1101");
            }
    
        }
        private void databind(string parentareacode)
        {
    
            var querydata = from q in context.ChinaStates
                        where q.ParentAreaCode == parentareacode
                        select q;
            DropDownList1.DataSource = querydata;//指定数据源
       
            //DropDownList1.Items.Insert(0,new ListItem("请选择单位"));
         
            DropDownList1.DataTextField = "AreaName";//界面上显示的是地名
            DropDownList1.DataValueField = "AreaCode";//存的是地区编号
       
            DropDownList1.DataBind();
    
    
        }
        private void datashibind(string parentareacode)
        {
            var querydata = from q in context.ChinaStates
                            where q.ParentAreaCode ==parentareacode
                            select q;
            DropDownList2.DataSource = querydata;
    
            DropDownList2.DataTextField = "AreaName";//界面上显示的是地名
            DropDownList2.DataValueField = "AreaCode";//存的是地区编号
            DropDownList2.DataBind();
    
        }
        private void dataxianbind(string parentareacode)
        {
    
            var querydata = context.ChinaStates.Where(r=>r.ParentAreaCode==parentareacode);
            DropDownList3.DataSource = querydata;
            DropDownList3.DataTextField = "AreaName";//界面上显示的是地名
            DropDownList3.DataValueField = "AreaCode";//存的是地区编号
            DropDownList3.DataBind();
    
        }
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string code = DropDownList1.SelectedValue.ToString();
            datashibind(code);
            if (DropDownList2.Items.Count > 0)
            {
                string s = DropDownList2.SelectedItem.Value.ToString();
                dataxianbind(s);
            }
            else 
            {
                DropDownList3.Items.Clear();
            }
           
       
          
    
        }
        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string code = DropDownList2.SelectedValue.ToString();
            dataxianbind(code);
    
        }
    }
  • 相关阅读:
    what's the 头寸
    pandas操作速查表
    基于TensorFlow的简单验证码识别
    Python识别字符型图片验证码
    使用python以及工具包进行简单的验证码识别
    Mac OS X中MacPorts安装和使用
    通过Tesseract实现简单的OCR
    报错解决——pytesseract.pytesseract.TesseractError: (1,’Error opening data file /usr/local/share/tessdata/eng.traineddata’)
    各版本系统安装tesseract-ocr
    报错解决——-bash: wget: command not found
  • 原文地址:https://www.cnblogs.com/liuyudong0825/p/4953076.html
Copyright © 2020-2023  润新知