• 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;
        }
    }  
    
  • 相关阅读:
    纯css切换左侧菜单
    HDU——T 1556 Color the ball
    CODEVS——T 1404 字符串匹配
    HDU——T 1506 Largest Rectangle in a Histogram|| POJ——T 2559 Largest Rectangle in a Histogram
    BZOJ——T 1113: [Poi2008]海报PLA
    POJ——T 2796 Feel Good
    November 27th 2016 Week 48th Sunday
    November 26th 2016 Week 48th Saturday
    November 25th 2016 Week 48th Friday
    November 24th 2016 Week 48th Thursday
  • 原文地址:https://www.cnblogs.com/lushixiong/p/4661378.html
Copyright © 2020-2023  润新知