protected void lbuRefresh_Click(object sender, EventArgs e)
 {
     ClearData();
     ClassGradLev gl = new ClassGradLev();
     DataTable dt = gl.GetGradLev("");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
 protected void lbuSearch_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtSearchGradLevName.Text))
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true);
         return;
     }
     else
     {
         ClassGradLev gl = new ClassGradLev();
         DataTable dt = gl.GetGradLev(txtSearchGradLevName.Text);
         GridView1.DataSource = dt;
         GridView1.DataBind();
         SetViewState(dt);
     }
 }
        protected void lbuSubmit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertGradLevName.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อระดับการศึกษา')", true);
                return;
            }
            ClassGradLev gl = new ClassGradLev();
            gl.GRAD_LEV_NAME = txtInsertGradLevName.Text;

            if (gl.CheckUseGradLevName())
            {
                gl.InsertGradLev();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะเพิ่ม มีอยู่ในระบบแล้ว !')", true);
            }
        }
        protected void modDeleteCommand(Object sender, GridViewDeleteEventArgs e)
        {
            string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
            ClassGradLev gl = new ClassGradLev();
            gl.GRAD_LEV_ID = id;
            gl.DeleteGradLev();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true);

            GridView1.EditIndex = -1;
            BindData1();
        }
 void BindData1()
 {
     ClassGradLev gl = new ClassGradLev();
     DataTable dt = gl.GetGradLev(txtSearchGradLevName.Text);
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
 void BindData()
 {
     ClassGradLev gl = new ClassGradLev();
     DataTable dt = gl.GetGradLev("");
     GridView1.DataSource = dt;
     GridView1.DataBind();
     SetViewState(dt);
 }
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            Label lblGradLevIDEdit = (Label)GridView1.Rows[e.RowIndex].FindControl("lblGradLevIDEdit");
            TextBox txtGradLevNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtGradLevNameEdit");

            ClassGradLev gl = new ClassGradLev(lblGradLevIDEdit.Text
                , txtGradLevNameEdit.Text);

            if (gl.CheckUseGradLevName())
            {
                gl.UpdateGradLev();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true);
                GridView1.EditIndex = -1;
                BindData1();
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะอัพเดท มีอยู่ในระบบแล้ว !')", true);
            }
        }