My addnew row button is only adding one row?

Discussion in 'ASP .Net' started by Luis Esteban Valencia, Mar 23, 2005.

  1. Please help me if possible
    Its only adding a row. When I click again it steps into the function but
    doesnt add it to the page.



    Private Sub LinkButton2_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles LinkButton2.Click

    Dim tcells As TableCellCollection

    'tcells = e.Item.Cells

    Dim lnkeliminarcel As New TableCell

    Dim productcell As New TableCell

    Dim cantidadcell As New TableCell

    Dim preciocell As New TableCell

    Dim taxescell As New TableCell

    Dim subtotalcell As New TableCell

    Dim ddlproductos As New DropDownList

    ddlproductos.AutoPostBack = True

    'ddlproductos = e.Item.Cells(1).FindControl("ddlproductos")

    ddlproductos.DataSource = CType(Session("productos"), DataSet)

    ddlproductos.DataTextField = "descripcion"

    ddlproductos.DataValueField = "idproducto"

    ddlproductos.DataBind()

    productcell.Controls.Add(ddlproductos)



    Dim lnkbutton As New LinkButton

    lnkbutton.Text = "Eliminar"

    lnkbutton.CommandName = "Delete"

    lnkeliminarcel.Controls.Add(lnkbutton)



    Dim txtcantidad As New TextBox

    txtcantidad.Text = 1

    txtcantidad.CssClass = "textos"

    txtcantidad.Width = Unit.Pixel(44)

    cantidadcell.Controls.Add(txtcantidad)

    Dim txtprecio As New TextBox

    txtprecio.CssClass = "textos"

    txtprecio.Width = Unit.Pixel(60)

    txtprecio.Text = objconsultas.precioxproducto(ddlproductos.SelectedValue)

    preciocell.Controls.Add(txtprecio)

    Dim txtivaporproducto As New TextBox

    txtivaporproducto.CssClass = "textos"

    txtivaporproducto.Width = Unit.Pixel(36)

    txtivaporproducto.Text =
    objconsultas.ivaporproducto(ddlproductos.SelectedValue)

    taxescell.Controls.Add(txtivaporproducto)

    Dim cantidad As Int32 = Convert.ToInt32(txtcantidad.Text)

    Dim price As Int32 = Convert.ToInt32(txtprecio.Text)

    Dim subtotal As Int32 = cantidad * price

    Dim txtsubtotalporproducto As New TextBox

    txtsubtotalporproducto.CssClass = "textos"

    txtsubtotalporproducto.Width = Unit.Pixel(68)

    txtsubtotalporproducto.Text = subtotal.ToString

    subtotalcell.Controls.Add(txtsubtotalporproducto)



    Dim di As New DataGridItem(0, 0, ListItemType.Item)

    di.Cells.Add(lnkeliminarcel)

    di.Cells.Add(productcell)

    di.Cells.Add(cantidadcell)

    di.Cells.Add(preciocell)

    di.Cells.Add(taxescell)

    di.Cells.Add(subtotalcell)

    dgpedidos.Controls(0).Controls.Add(di)

    End Sub





    <asp:datagrid id="dgpedidos" runat="server" Width="100%"
    AutoGenerateColumns="False">
    <ItemStyle CssClass="registros"></ItemStyle>
    <HeaderStyle CssClass="titulostablas"></HeaderStyle>
    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:LinkButton runat="server" Text="Eliminar"
    CommandName="Delete" CausesValidation="false"></asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Producto">
    <ItemTemplate>
    <asp:DropDownList id="ddlproductos" runat="server"
    AutoPostBack="True"></asp:DropDownList>
    </ItemTemplate>
    <FooterTemplate>
    <asp:LinkButton id="LinkButton1" runat="server"
    CommandName="agregarproducto">Agregar Producto</asp:LinkButton>
    </FooterTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Cantidad">
    <ItemTemplate>
    <asp:TextBox id="txtcantidad" runat="server" Width="44px"
    CssClass="textos" AutoPostBack="True"
    OnTextChanged="calcularsubtotal"></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Precio">
    <ItemTemplate>
    <asp:TextBox id=txtprecio runat="server" Width="60px"
    CssClass="textos" Text='<%# DataBinder.Eval(Container,
    "DataItem.precioespecifico") %>'>
    </asp:TextBox>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Iva">
    <ItemTemplate>
    <asp:TextBox id=txtivaporproducto runat="server" Width="36px"
    CssClass="textos" Text='<%# DataBinder.Eval(Container, "DataItem.iva") %>'>
    </asp:TextBox><FONT size="2">%</FONT>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Subtotal">
    <ItemTemplate>
    <asp:TextBox id="txtsubtotalporproducto" runat="server"
    Width="68px" CssClass="textos"></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:datagrid></P>
    </TD>
    </TR>
    <TR>
    <TD width="50%"></TD>
    <TD width="68" style="WIDTH: 68px"></TD>
    <TD width="15%"></TD>
    <TD width="15%"><STRONG><FONT
    size="3">Subtotal</FONT></STRONG></TD>
    <TD width="15%"><STRONG><FONT size="3"><asp:textbox
    id="txtsubtotalpedido" runat="server" Width="80px"
    CssClass="textos"></asp:textbox></FONT></STRONG></TD>
    </TR>
    <TR>
    <TD width="50%"><STRONG><FONT size="3">
    <asp:LinkButton id="LinkButton2" runat="server"
    CommandName="agregarproducto">Agregar Producto</asp:LinkButton>
    Luis Esteban Valencia, Mar 23, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tascien

    rs.AddNew in ado.net

    Tascien, Dec 26, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    6,231
    Scott M.
    Dec 30, 2003
  2. harbans

    Addnew fails when

    harbans, May 22, 2006, in forum: C++
    Replies:
    1
    Views:
    495
    mlimber
    May 22, 2006
  3. Roger Withnell
    Replies:
    9
    Views:
    305
    Aaron Bertrand - MVP
    Dec 2, 2003
  4. michal

    recordset.addNew() with postgres

    michal, Apr 13, 2007, in forum: ASP General
    Replies:
    7
    Views:
    278
    Bob Barrows [MVP]
    Apr 14, 2007
  5. c676228

    recordset.addNew

    c676228, Apr 28, 2009, in forum: ASP General
    Replies:
    6
    Views:
    564
    Vince Xu [MSFT]
    May 5, 2009
Loading...

Share This Page