<%@ Import namespace="System.Data" %>
<html>
<head>
<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack then
Dim dt As DataTable
Dim dr As DataRow
Dim i As Integer
'创建数据表
dt = New DataTable
dt.Columns.Add(New DataColumn("整数值", GetType(Integer)))
dt.Columns.Add(New DataColumn("字符串值", GetType(String)))
dt.Columns.Add(New DataColumn("日期时间值", GetType(DateTime)))
dt.Columns.Add(New DataColumn("布尔值", GetType(Boolean)))
'生成一些行,并在其中放置一些示例数据
For i = 1 To 9
dr = dt.NewRow()
dr(0) = i
dr(1) = "项 " + i.ToString()
dr(2) = DateTime.Now.ToShortTimeString
If (i Mod 2 <> 0) then
dr(3) = True
else
dr(3) = False
End If
'向数据表添加行
dt.Rows.Add(dr)
Next
dataGrid1.DataSource = new DataView(dt)
dataGrid1.DataBind
End If
End Sub
</script>
</head>
<body>
<h3><font face="宋体">到 DataView 的数据绑定</font></h3>
<form runat=server>
<asp
ataGrid id="dataGrid1" runat="server"
BorderColor="black"
BorderWidth="1"
GridLines="Both"
CellPadding="3"
CellSpacing="0"
HeaderStyle-BackColor="#aaaadd"
/>
</form>
</body>
</html>