Exemple #1
0
    //dropdownlist学院列绑定
    private void drpBind()
    {
        CollegesManage cm = new CollegesManage();

        DropDownList2.DataSource    = cm.Select();
        DropDownList2.DataTextField = "college";
        DropDownList2.DataBind();
    }
    //DropDownList2学院 绑定
    private void drpBind()
    {
        DataTable      dt = sm.SelectByValue(Request.QueryString["studentId"].ToString());
        CollegesManage cm = new CollegesManage();

        DropDownList2.DataSource    = cm.Select();
        DropDownList2.DataTextField = "college";
        DropDownList2.SelectedValue = dt.Rows[0]["college"].ToString();
        DropDownList2.DataBind();
    }
Exemple #3
0
    //dropdownlist学院列绑定
    private void drpBind()
    {
        TermsManage    tm = new TermsManage();
        CollegesManage cm = new CollegesManage();

        DropDownList1.DataSource    = tm.Select();
        DropDownList1.DataTextField = "term";
        DropDownList1.DataBind();
        DropDownList2.DataSource    = cm.Select();
        DropDownList2.DataTextField = "college";
        DropDownList2.DataBind();
        ddl3bind();
    }
    //触发gridview行的编辑事件
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;                    //设置GridView控件的编辑项的索引为选择的当前索引
        gridviewBind();                                          //数据绑定 为什么要放前面因为不绑定的话下面的gvr.FindControl("drppost")是为空的,也就是不重新绑定的话前台控件drppost是不会出现的
        GridViewRow    gvr     = GridView1.Rows[e.NewEditIndex]; //实例化一行
        DropDownList   drppost = (DropDownList)(gvr.FindControl("drppost"));
        CollegesManage cm      = new CollegesManage();
        string         n       = GridView1.DataKeys[e.NewEditIndex].Value.ToString(); //获取当前行主键id
        TeachersManage tm      = new TeachersManage();

        for (int i = 0; i < cm.Select().Rows.Count; i++)
        {
            string   college = cm.Select().Rows[i]["college"].ToString();
            ListItem item    = new ListItem(college);
            if (college == tm.SelectByValue(n).Rows[0]["college"].ToString())
            {
                item.Selected = true;
            }
            drppost.Items.Add(item);
        }
    }