Beispiel #1
0
        //Update PromoGridView with exception handling
        protected void UpGV1(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow row = PromoGridView.Rows[e.RowIndex];

                string   promoCode     = (row.FindControl("Label1") as Label).Text;
                short    discount      = short.Parse((row.FindControl("TextBox2") as TextBox).Text);
                DateTime validStart    = (row.FindControl("Calendar3") as Calendar).SelectedDate;
                int      promoDuration = Convert.ToInt32((row.FindControl("TextBox4") as TextBox).Text);

                BusinessLogic.UpdatePromoCode(promoCode, discount, validStart, promoDuration);
                PromoGridView.EditIndex = -1;

                PromoGridView.DataSource = BusinessLogic.Promos();
                PromoGridView.DataBind();
                Label7.Text = "Update success!";
            }
            catch (Exception)
            {
                Label7.Text = "Please input a valid discount amount and duration.";
            }
        }