<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <asp:Table BorderWidth="1px" ID="myTable" runat="server" Width="100%"> <asp:TableRow BorderWidth="3px"> <asp:TableCell> Table One for USA </asp:TableCell> </asp:TableRow> </asp:Table> <br /> <asp:Button ID="Button988" runat="server" Text="Button" onclick="Button988_Click" /> <br /> <asp:Table BorderWidth="1px" ID="myTable2" runat="server" Width="100%"> <asp:TableRow BorderWidth="3px"> <asp:TableCell>Table Two for UK </asp:TableCell> </asp:TableRow> </asp:Table> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button988_Click" /> </asp:Content>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { TextBox tb1 = new TextBox(); TextBox tb2 = new TextBox(); Button b1 = new Button(); TextBox tb3 = new TextBox(); TextBox tb4 = new TextBox(); Button b2 = new Button(); protected void Page_Load(object sender, EventArgs e) { b1.Text = "-"; b1.Click += new EventHandler(b1_Click); } protected void Button988_Click(object sender, EventArgs e) { TableRow tRow = new TableRow(); myTable.Rows.Add(tRow); TableCell tCell1 = new TableCell(); TableCell tCell2 = new TableCell(); TableCell tCell3 = new TableCell(); tRow.Cells.Add(tCell1); tRow.Cells.Add(tCell2); tRow.Cells.Add(tCell3); tCell1.Controls.Add(tb1); tCell1.Controls.Add(tb2); tCell1.Controls.Add(b1); tRow.Visible = true; } protected void Button1_Click(object sender, EventArgs e) { TableRow tRow = new TableRow(); myTable2.Rows.Add(tRow); TableCell tCell4 = new TableCell(); TableCell tCell5 = new TableCell(); TableCell tCell6 = new TableCell(); tRow.Cells.Add(tCell4); tRow.Cells.Add(tCell5); tRow.Cells.Add(tCell6); tCell4.Controls.Add(tb3); tCell5.Controls.Add(tb4); tCell6.Controls.Add(b2); tRow.Visible = true; } void b1_Click(object sender, EventArgs e) { tb1.Dispose(); tb2.Dispose(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)