コード例 #1
0
    private void LoadGrid()
    {
        try
        {
            string course_id = Request.QueryString["val1"];
            string sectionid = Request.QueryString["val2"];
            string teacherID = Request.QueryString["val3"];

            BLItem objBL = new BLItem();                                                      // declare and initialize BLItem object
            Students.DataSource = objBL.getEnrolledStudents(course_id, sectionid, teacherID); //setting data source for the gridview
            Students.DataBind();                                                              //bind the data source to the gridview
            if (Students.Rows.Count > 0)
            {
                Students.BorderStyle           = BorderStyle.None;
                Students.HeaderRow.ForeColor   = Color.Khaki;
                Students.HeaderRow.BorderStyle = BorderStyle.None;
                Students.GridLines             = GridLines.None;

                for (int i = 0; i < Students.Rows.Count; i++)
                {
                    Students.Rows[i].BorderStyle = BorderStyle.None;
                    for (int j = 0; j < Students.Columns.Count; j++)
                    {
                        Students.Rows[i].Cells[j].BorderStyle = BorderStyle.None;
                    }
                    Students.Rows[i].ForeColor = Color.White;
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('No Students in this class')", true);
            }
        }
        catch (SqlException)
        {
            throw;
        }
    }