protected void btnsubmit_Click(object sender, EventArgs e)
 {
     try
     {
         CategoryMaster cm = new CategoryMaster();
         if (btnsubmit.Text == "Submit")
         {
             cm.CATEGORY_ID   = CategoryMaster.MaxID() + 1;
             cm.CATEGORY_NAME = txtcategory.Text;
             cm.REMARK        = txtremark.Text;
             cm.Save();
             grid();
             ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Submit Successfully....');</Script>", false);
         }
         else if (btnsubmit.Text == "Update")
         {
             cm               = CategoryMaster.GetByCATEGORY_ID(int.Parse(ViewState["id"].ToString()));
             cm.CATEGORY_ID   = int.Parse(ViewState["id"].ToString());
             cm.CATEGORY_NAME = txtcategory.Text;
             cm.REMARK        = txtremark.Text;
             cm.Save();
             grid();
             ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Update Successfully...');</Script>", false);
         }
         ClearInputs(Page.Controls);
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert(error);</script>", false);
     }
 }
        protected void linkbtnEdit_Click(object sender, EventArgs e)
        {
            LinkButton  lb = (LinkButton)sender;
            GridViewRow gr = (GridViewRow)lb.NamingContainer;

            ViewState["id"] = ((Label)gr.FindControl("labelNOTICE_ID")).Text;
            string         nid = ViewState["id"].ToString();
            CategoryMaster dm  = CategoryMaster.GetByCATEGORY_ID(int.Parse(nid));

            txtcategory.Text = dm.CATEGORY_NAME;
            txtremark.Text   = dm.REMARK;
            btnsubmit.Text   = "Update";
        }