formdatasoure02.aspx
来自「asp做的新闻系统」· ASPX 代码 · 共 64 行
ASPX
64 行
<html>
<script language="vb" runat=server>
'定义一个类用于保存姓名
Public Class PName
private first_name as String
private last_name as String
Public Property Fname as String
Get
return first_name
End Get
Set
first_name=value
End Set
End Property
Public Property Lname as String
Get
return last_name
End Get
Set
last_name=value
End Set
End Property
'创建实例
Public Sub New(f as String,l as String)
MyBase.New
first_name=f
last_name=l
End Sub
End Class
Sub Page_Load(o as object,e as eventargs)
dim ht as New HashTable
if Not IsPostBack
'hash Table 的Add方法所带参数为:索引,对象
ht.add("1",New PName("Bennet","Abraham"))
ht.add("2",New PName("Blotchet-Halls","Reginald"))
ht.add("3",New PName("Carson","Cheryl"))
ht.add("4",New PName("DeFrance","Michel"))
ht.add("5",New PName("del Castillo","Innes"))
DtGrd.datasource=ht.values
DtGrd.databind
'数据绑定到hashtable上
End if
End Sub
</script>
<head>
<title>
数据绑定试验
</title>
</head>
<body bgcolor=#ccccff>
<center>
<h2>数据绑定之数据源试验(HashTable)</h2>
<hr>
<form runat=server>
<asp:DataGrid id="DtGrd" runat=server/>
</form>
</center>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?