Imports System.Data Imports System.Configuration Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls Partial Public Class [Default2] Inherits System.Web.UI.Page Private numOfColumns As Integer = 1 Private ctr As Integer = 0 Private table As Table = Nothing Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not IsPostBack Then table = New Table() table.ID = "tableBuild" Session("table") = table ViewState("ctr") = ctr End If ctr = CType(ViewState("ctr"), Int32) table = DirectCast(Session("table"), Table) Panel1.Controls.Add(table) End Sub Private Sub GenerateTable(ByVal colsCount As Integer) ctr += 1 Dim row As New TableRow() Dim cell As New TableCell() Dim tb As New TextBox() tb.ID = "TextBoxRow_" & ctr tb.Width = 80 ' Add the control to the TableCell cell.Controls.Add(tb) ' Add the TableCell to the TableRow row.Cells.Add(cell) Dim cell1 As New TableCell() Dim dd As New DropDownList dd.ID = "dd1" & ctr dd.Width = 80 Dim tb1 As New TextBox() tb1.ID = "TextBox1Row_" & ctr tb1.Width = 80 ' Add the control to the TableCell cell1.Controls.Add(tb1) '---------- cell1.Controls.Add(dd) '------------------------ ' Add the TableCell to the TableRow row.Cells.Add(cell1) ' Add the TableRow to the Table table.Rows.Add(row) Session("table") = table ViewState("ctr") = ctr End Sub Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click numOfColumns = 1 'Generate the Table based from the inputs GenerateTable(numOfColumns) End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)