asp.net实例代码之定义与使用asp:AccessDataSource,如下:
复制代码 代码示例:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>DataList From Access</title>
</head>
<body>
<form id="form1" runat="server">
<asp:DataList ID="DataList1" runat="server" DataSourceID="AccessDataSource1" DataKeyField="CategoryID"
RepeatColumns="3" RepeatDirection="Horizontal">
<ItemTemplate>
<table>
<tr>
<td style="width: 100px">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("CategoryID") %>'></asp:Label>
</td>
</tr>
<tr>
<td style="width: 100px">
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
</td>
<td style="width: 100px">
<asp:Label ID="Label3" runat="server" Text='<%# Eval("CategoryName") %>'></asp:Label>
</td>
</tr>
</table>
<br />
<br />
</ItemTemplate>
</asp:DataList>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="Northwind.mdb"
SelectCommand="SELECT * FROM [Categories]"></asp:AccessDataSource>
</form>
</body>
</html>