<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
Untitled Page
File: Default.aspx.vb
Partial Class _Default
Inherits System.Web.UI.Page
Private Property myCounter() As Integer
Get
Return CInt(Cache("myCounter"))
End Get
Set(ByVal Value As Integer)
Cache("myCounter") = Value
End Set
End Property
Private ReadOnly Property RowTexts() As ArrayList
Get
Dim al As ArrayList
al = CType(Cache("rowTexts"), ArrayList)
If IsNothing(al) Then
al = New ArrayList()
Cache("rowTexts") = al
End If
Return al
End Get
End Property
Private Sub AddARow(ByVal s As String)
Dim cell As New TableCell()
Dim row As New TableRow()
cell.Text = s
row.Cells.Add(cell)
Table1.Rows.Add(row)
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
myCounter += 1
Label1.Text = myCounter.ToString()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
RowTexts.Add(TextBox1.Text)
AddARow(TextBox1.Text)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim s As String
For Each s In RowTexts
AddARow(s)
Next
End Sub
End Class