private void CargarGrilla() { DataSet ds = ListCompra.GetCompras(); gridCompras.DataSource = ds.Tables[0]; gridCompras.DataBind(); }
protected void gridCompras_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "EditarCompra") { string sCompraId = e.CommandArgument.ToString(); Response.Redirect("EditCompra.aspx?Id=" + sCompraId); } else if (e.CommandName == "EliminarCompra") { Compra compra = new Compra(); compra.Id = Convert.ToInt32(e.CommandArgument.ToString()); ListCompra.DeleteCompra(compra); CargarGrilla(); } } catch (Exception ex) { messageBox.ShowMessage(ex.Message + ex.StackTrace); } }