|
Source code for CategoryDG.aspx
-- Using DataGrid and Data Set

=== code listing ===
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data.OleDb" %>
<%@ import Namespace="System.Data" %>
<script runat="server">
Sub Page_Load( ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim conn As OleDbConnection
conn = New _
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("db/Northwind.mdb") )
Dim ds As DataSet = New DataSet()
Dim da As OleDbDataAdapter = New _
OleDbDataAdapter("select * from Categories", conn)
da.Fill(ds, "Categories")
' Use a DataView as a DataSource
DataGrid1.DataSource = ds.Tables("Categories").DefaultView
DataGrid1.DataBind()
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<font size="4"><strong>A List of Categories</strong></font>
</p>
<p>
<asp:DataGrid id="DataGrid1" runat="server" Height="230px"></asp:DataGrid>
</p>
</form>
</body>
</html>
|