469,934 Members | 2,179 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

My addnew row button is only adding one row?

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.Selected Value)

preciocell.Controls.Add(txtprecio)

Dim txtivaporproducto As New TextBox

txtivaporproducto.CssClass = "textos"

txtivaporproducto.Width = Unit.Pixel(36)

txtivaporproducto.Text =
objconsultas.ivaporproducto(ddlproductos.SelectedV alue)

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>

Nov 19 '05 #1
0 1291

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

25 posts views Thread by dixie | last post: by
5 posts views Thread by Mika M | last post: by
2 posts views Thread by pillmill | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.