Here's all the code I have.
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="dgdyamic.aspx.vb"
Inherits="p4320work.dgdyamic"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>dgdyamic</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="
http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp
laceHolder id="PlaceHolder1" runat="server"></asp
laceHolder>
</form>
</body>
</HTML>
'----------------------------------------------------------
Public Class dgdyamic
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Protected WithEvents PlaceHolder1 As
System.Web.UI.WebControls.PlaceHolder
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim Answers As New DataGrid
With Answers
.AllowPaging = True
.PageSize = 5
.DataSource = Data()
.DataBind()
End With
PlaceHolder1.Controls.Add(Answers)
AddHandler Answers.PageIndexChanged, _
AddressOf ChangePage
End Sub
Sub ChangePage _
(ByVal source As Object, _
ByVal e As DataGridPageChangedEventArgs)
' This procedure handles events raised by the object source.
Response.Write("Event fired. " & _
e.NewPageIndex.ToString) ' Handle the event.
End Sub
Function Data() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource
End Class