473,322 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 1390

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: dixie | last post by:
I have some code that adds new records into a table for each ID in a list box when a button on a form is clicked. This works fine. My problem now is that I wish to be able to edit all the records...
1
by: Ryan | last post by:
Hello, I have a quick question (I hope). I have a form with a combo box and a multi-selection list box. The list box is based on a query. Users can select values from the cmbobox to add to...
5
by: Mika M | last post by:
Hello! I have Windows Forms application form containing TextBoxes, six ComboBoxes, and DataGrid for details. I have created DataSet with needed tables, and created relations between tables, and...
6
by: Aaron Smith | last post by:
I have a form, oddly enough the same one with the expression column that is giving me a headache, and on this form I have a dataset that has a couple of tables in it that are related. If I do a...
2
by: pillmill | last post by:
I replaced AddNew statments with INSERT INTO, but am unable to write to the same tables. Foreign keys violations are the main errors. Why are these occuring ? Before: set rs3=...
8
by: MLH | last post by:
Here's a snippet from A97 HELP on AddNew... The record that was current before you used AddNew remains current. If you want to make the new record current, you can set the Bookmark property to...
9
bhcob1
by: bhcob1 | last post by:
Hey guys, 'Update or CancelUpdate without AddNew or Edit' On my database i keep occasionly get this error when i try and edit a field, it is not everytime. It will be working fine and then this...
1
by: teenagelcruise | last post by:
hi, i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote. <html> <head> <meta...
4
by: mayen001 | last post by:
Hi First time i am posting a question so here goes... I have created a bit of VBA for pupils where the aim is: input line of text from file;parse the input line and extract values; using the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.