TPetersonFlorida
Programmer
I have a web form with a button on it. I have a table with one row already pre-defined. What i want to happen is the user clicks the button to append another row onto the table, in essence have the ability to append as many rows as they would like. I can get it to create one row but after that all subsequent button clicks are overwriting the row already created. any ideas?
my code behind the button:
Private Sub btnAddRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddRow.Click
Dim myCell As New TableCell()
Dim myRow As New TableRow()
myCell.Controls.Add(New LiteralControl(Date.Now))
myCell.BorderStyle = BorderStyle.Solid
myCell.BorderWidth = Unit.Pixel(1)
myRow.Cells.Add(myCell)
myTable.Rows.Add(myRow)
End Sub
my html code for the page:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="DynamicTable.aspx.vb" Inherits="Ecore.DynamicTable"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>DynamicTable</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content=" </HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="btnAddRow" style="Z-INDEX: 101; LEFT: 11px; POSITION: absolute; TOP: 6px" runat="server" Text="Add Row"></asp:Button>
<asp:Label id="lblCount" style="Z-INDEX: 102; LEFT: 112px; POSITION: absolute; TOP: 9px" runat="server">Label</asp:Label>
<asp:Table id="myTable" style="Z-INDEX: 103; LEFT: 17px; POSITION: absolute; TOP: 46px" runat="server" Width="445px"></asp:Table>
</form>
</body>
</HTML>
my code behind the button:
Private Sub btnAddRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddRow.Click
Dim myCell As New TableCell()
Dim myRow As New TableRow()
myCell.Controls.Add(New LiteralControl(Date.Now))
myCell.BorderStyle = BorderStyle.Solid
myCell.BorderWidth = Unit.Pixel(1)
myRow.Cells.Add(myCell)
myTable.Rows.Add(myRow)
End Sub
my html code for the page:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="DynamicTable.aspx.vb" Inherits="Ecore.DynamicTable"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>DynamicTable</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content=" </HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="btnAddRow" style="Z-INDEX: 101; LEFT: 11px; POSITION: absolute; TOP: 6px" runat="server" Text="Add Row"></asp:Button>
<asp:Label id="lblCount" style="Z-INDEX: 102; LEFT: 112px; POSITION: absolute; TOP: 9px" runat="server">Label</asp:Label>
<asp:Table id="myTable" style="Z-INDEX: 103; LEFT: 17px; POSITION: absolute; TOP: 46px" runat="server" Width="445px"></asp:Table>
</form>
</body>
</HTML>