protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.QueryString["id"] != null) { cargarCaracter(int.Parse(Request.QueryString["id"])); } CaracterApp objCaracter = new CaracterApp(); dgCaracter.DataSource = objCaracter.TraerDatos(); dgCaracter.DataBind(); } }
private void btnAceptar_Click(object sender, EventArgs e) { if (TxtCaracter.Text != "") { if (hidCaracter.Value != "") { CaracterApp objCaracter = new CaracterApp(); objCaracter.Modificar(int.Parse(hidCaracter.Value), TxtCaracter.Text); } else { CaracterApp objCaracter = new CaracterApp(); objCaracter.Crear(TxtCaracter.Text); } } Response.Redirect("abmlCaracter.aspx"); }
private void dgCaracter_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.Item.Cells[0].Text != "") { switch (((ImageButton)e.CommandSource).CommandName) { case "Cancelar": int IdCodigo = int.Parse(e.Item.Cells[0].Text); CaracterApp objCaracter = new CaracterApp(); objCaracter.Eliminar(IdCodigo); Response.Redirect("abmlCaracter.aspx"); break; case "Editar": Response.Redirect("abmlCaracter.aspx?id=" + e.Item.Cells[0].Text); break; } } }