码迷,mamicode.com
首页 > 其他好文 > 详细

dropdownlist 二级联动

时间:2015-03-09 10:40:34      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            GradeBind();
        }

    }

    //绑定年级
    private void GradeBind()
    {
        Rubric.BLL.Grades myBll = new Rubric.BLL.Grades();
        ddlGrade.DataSource = myBll.GetAllList();
        ddlGrade.DataTextField = "Name";
        ddlGrade.DataValueField = "GradeId";
        ddlGrade.DataBind();
    }
    //ddlGrade的selectindexchanged事件
    protected void ddlGrade_SelectedIndexChanged(object sender, EventArgs e)
    {
        string _gradeId = ddlGrade.SelectedValue.ToString();
        string _str = "GradeId=‘" + _gradeId + "‘";
        Rubric.BLL.Courses myBll = new Rubric.BLL.Courses();
        DataSet ds = myBll.GetList(_str);
        ddlCourse.DataSource = ds;
        ddlCourse.DataTextField = "Name";
        ddlCourse.DataValueField = "CourseId";
        ddlCourse.DataBind();
    }

dropdownlist 二级联动

标签:

原文地址:http://www.cnblogs.com/wanshutao/p/4322885.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!