zoukankan      html  css  js  c++  java
  • webform 下拉列表联动

    ublic partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDown();
            }
           
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string userName = TextBox1.Text;
            string userPass = TextBox2.Text;        
            //HttpCookie cookie = Request.Cookies["userName"];
            ////string value = cookie.Value;
            //if (cookie.Value == user)
            //{
            //    HttpCookie cookie2 = Request.Cookies["userPass"];
            //    TextBox2.Text = cookie2.Value;
            //}
            bool user = new UserdBF().Select(userName, userPass);
            if (user)
            {
                if (CheckBox1.Checked)
                {
                    HttpCookie cookie1 = new HttpCookie("userName", userName);
                    cookie1.Expires = DateTime.Now.AddHours(2);
                    Response.SetCookie(cookie1);
                    HttpCookie cookie2 = new HttpCookie("userPass", userPass);
                    cookie2.Expires = DateTime.Now.AddHours(2);
                    Response.SetCookie(cookie1);
                }
                Response.Write("<script>alert('登录成功');</script>");
            }
            else
            {
                Response.Write("<script>alert('用户名或密码错误');</script>");
            }
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("Default2.aspx");
        }
        public void DropDown()
        {
            List<AreaFull> list = new AreaBF().Select(0);
            DropDownList1.DataSource = list;
            DropDownList1.DataTextField = "AreaName";
            DropDownList1.DataValueField = "AreaId";
            DropDownList1.DataBind();
            int a = Convert.ToInt32(DropDownList1.SelectedItem.Value);
            List<AreaFull> listS = new AreaBF().Select(a);
            DropDownList2.DataSource = listS;
            DropDownList2.DataTextField = "AreaName";
            DropDownList2.DataValueField = "AreaId";
            DropDownList2.DataBind();
            int b = Convert.ToInt32(DropDownList2.SelectedItem.Value);
            List<AreaFull> listQ = new AreaBF().Select(b);
            DropDownList3.DataSource = listQ;
            DropDownList3.DataTextField = "AreaName";
            DropDownList3.DataValueField = "AreaId";
            DropDownList3.DataBind();
            TextBox3.Text = DropDownList1.SelectedItem.Text + DropDownList2.SelectedItem.Text + DropDownList3.SelectedItem.Text;
           
        }
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int a = Convert.ToInt32(DropDownList1.SelectedItem.Value);
            List<AreaFull> listS = new AreaBF().Select(a);
            DropDownList2.DataSource = listS;
            DropDownList2.DataTextField = "AreaName";
            DropDownList2.DataValueField = "AreaId";
            DropDownList2.DataBind();
            int b = Convert.ToInt32(DropDownList2.SelectedItem.Value);
            List<AreaFull> listQ = new AreaBF().Select(b);
            DropDownList3.DataSource = listQ;
            DropDownList3.DataTextField = "AreaName";
            DropDownList3.DataValueField = "AreaId";
            DropDownList3.DataBind();
            TextBox3.Text = DropDownList1.SelectedItem.Text + DropDownList2.SelectedItem.Text + DropDownList3.SelectedItem.Text;
        }
        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            int b = Convert.ToInt32(DropDownList2.SelectedItem.Value);
            List<AreaFull> listQ = new AreaBF().Select(b);
            DropDownList3.DataSource = listQ;
            DropDownList3.DataTextField = "AreaName";
            DropDownList3.DataValueField = "AreaId";
            DropDownList3.DataBind();
            TextBox3.Text = DropDownList1.SelectedItem.Text + DropDownList2.SelectedItem.Text + DropDownList3.SelectedItem.Text;
        }
        protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
        {
            TextBox3.Text = DropDownList1.SelectedItem.Text + DropDownList2.SelectedItem.Text + DropDownList3.SelectedItem.Text;
        }
    }  
    
  • 相关阅读:
    第一次会议(2019.3.4)
    改革春风吹满地小组~~成立了~~⭐😄~~
    PYQT5 系列(一)——参考自《弗兰克万岁》
    Springboot2.0学习笔记1__微服务及springboot的作用
    Java学习之---------------反射
    Jquery对select的操作 添加一个select
    匿名函数
    数据库迁移
    EF 未应用自动迁移,因为自动迁移会导致数据丢失的解决办法
    在Chrome+Visual Studio中调试asp.net程序很慢的问题(Firefox也有类似问题)
  • 原文地址:https://www.cnblogs.com/lushixiong/p/4661378.html
Copyright © 2011-2022 走看看