コード例 #1
0
 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         long id = long.Parse(GridView1.DataKeys[e.RowIndex].Values["Id"].ToString());
         DefaultController.DeleteProduct(id);
         string script = @"<script type='text/javascript'>
                     alert('{0}');
                 </script>";
         script = string.Format(script, "Producto eliminado correctamente");
         ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
         this.setTableProducts();
     }
     catch (Exception ex)
     {
         string script = @"<script type='text/javascript'>
                     alert('{0}');
                 </script>";
         script = string.Format(script, ex.Message);
         ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
     }
 }