Exemplo n.º 1
0
 /** 以下為各控制項內置的方法 **/
 // 頁面載入時,觸發此方法
 protected void Page_Load(object sender, EventArgs e)
 {
     // 第一次載入頁面時
     // 自動選擇最小的學期並顯示資料
     // (美觀,可避免尚未搜尋資料時的頁面空白)
     if (!IsPostBack)
     {
         Batch_DDL.SelectedIndex = 0;
         Batch_DDL.DataBind();
         SemesterChanged(int.Parse(Batch_DDL.SelectedValue));
     }
 }
        //當使用者變更下拉式選單內所選的期別時,觸發此方法
        protected void Batch_DDL_SelectedIndexChanged(object sender, EventArgs e)
        {
            //接收自控制項傳入的資料,
            //以讓多個控制項共用同一方法,達成精簡程式碼的目的
            Selected_Batch_DDL = (DropDownList)sender;

            Batch_DDL.DataBind();
            Batch_DDL.SelectedValue = Selected_Batch_DDL.SelectedValue;

            int Batch = int.Parse(Selected_Batch_DDL.SelectedValue);

            //根據使用者所選期別,自資料表內調出資料
            //調出學生資料
            Student_SDS_ForGV.SelectCommand =
                "SELECT Student.ID, Name, Ch_Title, First_Commit, Second_Commit, Third_Commit, First_Prof FROM Student WHERE Batch = " + Batch + ";";
            //調出教師資料
            Teacher_SDS_ForGV.SelectCommand =
                "SELECT * FROM [Teacher] , [ExamPoint_Log] WHERE Batch = " + Batch + ";";

            //刷新頁面中四個Grid_View控制項,以更新顯示內容
            Student_GV.DataBind();
            Teacher_GV.DataBind();

            //計算Student_GV共有幾列資料
            int ST_DataRow = Student_GV.Rows.Count;

            //將指導教師及三名審查委員之資料(教師編號)替換為相對應的教師姓名
            int    Row_Count = 0;
            int    Col_Count;
            string Data_Value;

            //
            while (Row_Count < ST_DataRow)
            {
                for (Col_Count = 6; Col_Count <= 8; Col_Count++)
                {
                    Data_Value = Student_GV.Rows[Row_Count].Cells[Col_Count].ToString();
                    //Student_GV.Rows[Row_Count].Cells[Col_Count] = ;
                }
                Row_Count++;
            }
        }