protected void Page_Load(object sender, EventArgs e)
 {
     Page.Form.DefaultFocus  = TextBoxSearch.ClientID;
     Page.Form.DefaultButton = ButtonSearch.UniqueID;
     if (!IsPostBack)
     {
         string searchValue = "%";
         GridViewResult.DataSource = Catman.GetCatmanListByFilter(searchValue);
         GridViewResult.DataBind();
     }
 }
 private void BindCatman()
 {
     try
     {
         Catman catman = Catman.GetCatmanByCatmanId(this.catmanId);
         TextBoxDescription.Text = catman.Description;
     }
     catch (System.Data.SqlClient.SqlException sqlEx)
     {
         for (int i = 0; i < sqlEx.Errors.Count; i++)
         {
             LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
         }
         PanelError.Visible = true;
     }
     catch (Exception exception)
     {
         LabelError.Text   += (exception.Message + "<br />");
         PanelError.Visible = true;
     }
 }
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Catman catman = new Catman();
                catman.CatmanId     = this.catmanId;
                catman.Description  = TextBoxDescription.Text;
                catman.ModifiedUser = Context.User.Identity.GetUserName();

                try
                {
                    catman.Save();
                    int catmanId = catman.CatmanId;

                    Button clickedButton = (Button)sender;
                    switch (clickedButton.ID)
                    {
                    case "ButtonSave":
                        Response.Redirect(String.Format("CatmanList.aspx?Description={0}", catman.Description));
                        break;

                    case "ButtonSaveNew":
                        Response.Redirect("CatmanEdit.aspx");
                        break;
                    }
                }
                catch (System.Data.SqlClient.SqlException sqlEx)
                {
                    LabelError.Text = "";
                    for (int i = 0; i < sqlEx.Errors.Count; i++)
                    {
                        ErrorMessage.Text += (sqlEx.Errors[i].Message + "<br />");
                    }
                }
            }
        }
 protected void ButtonSearch_Click(object sender, EventArgs e)
 {
     GridViewResult.DataSource = Catman.GetCatmanListByFilter("%" + TextBoxSearch.Text + "%");
     GridViewResult.DataBind();
 }