protected void Page_Load(object sender, EventArgs e)
 {
     Page.Form.DefaultFocus  = TextBoxSearch.ClientID;
     Page.Form.DefaultButton = ButtonSearch.UniqueID;
     if (!IsPostBack)
     {
         string searchValue = "%";
         GridViewResult.DataSource = CategoryReduction.GetCategoryReductionListByFilter(searchValue);
         GridViewResult.DataBind();
     }
 }
 private void BindCategoryReduction()
 {
     try
     {
         CategoryReduction categoryReduction = CategoryReduction.GetCategoryReductionByCategoryReductionId(this.categoryReductionId);
         TextBoxDescription.Text = categoryReduction.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)
            {
                CategoryReduction categoryReduction = new CategoryReduction();
                categoryReduction.CategoryReductionId = this.categoryReductionId;
                categoryReduction.Description         = TextBoxDescription.Text;
                categoryReduction.ModifiedUser        = Context.User.Identity.GetUserName();

                try
                {
                    categoryReduction.Save();
                    int categoryReductionId = categoryReduction.CategoryReductionId;

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

                    case "ButtonSaveNew":
                        Response.Redirect("CategoryReductionEdit.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 = CategoryReduction.GetCategoryReductionListByFilter("%" + TextBoxSearch.Text + "%");
     GridViewResult.DataBind();
 }