DropDownList 二级菜单联动

添加人:guorui1314零级(44分)   添加时间:2008-05-28    阅读次数:430  收藏此教程

protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            DropDowsList1();

           }
    }
 public void DropDowsList1()
    {
        con.Open();

        da = new SqlDataAdapter("select * from Products", con);
        da.Fill(ds);

        DropDownList1.DataValueField = "ProductID";
        DropDownList1.DataTextField = "ProductName";
        DropDownList1.DataSource = ds.Tables["Products"];
        DropDownList1.DataBind();
    }

    public void DropDowsList2()
    {
        con.Open();
        da = new SqlDataAdapter("select ProductID,ProductName from Products  where ProductID = '" + DropDownList1.Text + "'", con);
        da.Fill(ds);
        DropDownList2.DataValueField = "ProductID";
        DropDownList2.DataTextField = "ProductName";
        DropDownList2.DataSource = ds.Tables["Products"];
        DropDownList2.DataBind();
    }
    
   //改变事件

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDowsList2();
    }

1页 第1上一页1下一页
相关的教程: 二级菜单联动
收藏此教程 到论坛求助

当前平均分: -1.3(6 次打分)

012345678910
评论主题
您的大名
您的评论
验证码 点击换一个验证码
知识库搜索: