protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox txtMonto = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtMonto"); DropDownList ddlCodRet = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlCodRet") as DropDownList; decimal Monto; try { Monto = Convert.ToDecimal(txtMonto.Text); } catch (ExcepcionesPersonalizadas.Presentacion ex) { throw new ExcepcionesPersonalizadas.Presentacion("Debe ingresar el monto"); } CodRetType cod = LCodRet.BuscarCodRet(ddlCodRet.SelectedItem.Text); RetencPercepType ret = new RetencPercepType(cod, Monto); DropDownList ddlIndFact = GridView1.Rows[e.RowIndex].FindControl("ddlIndFact") as DropDownList; int idInd = Convert.ToInt32(ddlIndFact.SelectedValue); IndicadorFacturaType IndFact = LIndicadorFacturaType.BuscarIndicadorFactura(idInd); List <RetencPercepType> l = new List <EntidadesCompartidas.RetencPercepType>(); l.Add(ret); Item_Resg item = new Item_Resg(((List <Item_Resg>)Session["ItemsRes"]).Count, IndFact, l); GridView1.EditIndex = -1; BindData(); }
protected void btnAdd(object sender, EventArgs e) { Button btnAdd = GridView1.FooterRow.FindControl("btnAdd") as Button; if (btnAdd != null) { TextBox txtNewMonto = GridView1.FooterRow.FindControl("txtMonto") as TextBox; if (txtNewMonto != null) { DropDownList ddlCodRetFoot = GridView1.FooterRow.FindControl("ddlCodRet") as DropDownList; if (ddlCodRetFoot != null) { string id = ddlCodRetFoot.SelectedItem.Text; decimal MontoNuevo; try { MontoNuevo = Convert.ToInt32(txtNewMonto.Text); } catch (ExcepcionesPersonalizadas.Presentacion ex) { throw new ExcepcionesPersonalizadas.Presentacion("Debe ingresar el monto nuevo"); } DropDownList ddlIndFact = GridView1.FooterRow.FindControl("ddlIndFact") as DropDownList; int idInd = Convert.ToInt32(ddlIndFact.SelectedValue); IndicadorFacturaType IndFact = LIndicadorFacturaType.BuscarIndicadorFactura(idInd); CodRetType cod = LCodRet.BuscarCodRet(id); RetencPercepType ret = new RetencPercepType(cod, MontoNuevo); List <RetencPercepType> l = new List <EntidadesCompartidas.RetencPercepType>(); l.Add(ret); Item_Resg item = new Item_Resg(((List <Item_Resg>)Session["ItemsRes"]).Count, IndFact, l); BindData(); } } } }