ASP.Net/ADO.net Database/Repeater
<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
If Not IsPostBack Then
Dim DBConn as OleDbConnection
Dim DBCommand As OleDbDataAdapter
Dim DSPageData as New DataSet
DBConn = New OleDbConnection( _
"PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("EmployeeDatabase.mdb;"))
DBCommand = New OleDbDataAdapter _
("Select ID, FirstName " _
& "From Employee " _
& "Order By FirstName", DBConn)
DBCommand.Fill(DSPageData, _
"Employee")
repDepts.DataSource = _
DSPageData.Tables("Employee").DefaultView
repDepts.DataBind()
End If
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Creating a Basic Repeater Control</TITLE>
</HEAD>
<Body LEFTMARGIN="40">
<form runat="server">
<asp:repeater
id="repDepts"
runat="server"
>
<headertemplate>
<I>Below is a list of all the employee.</I><BR><BR>
</headertemplate>
<itemtemplate>
<%# "<B>Department:</B> " _
& DataBinder.Eval(Container.DataItem, "ID") _
& " - " _
& DataBinder.Eval(Container.DataItem, "FirstName")
%>
<BR>
</itemtemplate>
<alternatingitemtemplate>
<I><%# "<B>Department:</B> " _
& DataBinder.Eval(Container.DataItem, "ID") _
& " - " _
& DataBinder.Eval(Container.DataItem, "FirstName")
%></I>
<BR>
</alternatingitemtemplate>
<separatortemplate>
<HR>
</separatortemplate>
<footertemplate>
<BR><I>All records have been displayed.</I>
</footertemplate>
</asp:repeater>
</form>
</BODY>
</HTML>
<A href="http://www.nfex.ru/Code/ASPDownload/EmployeeDatabase.zip">EmployeeDatabase.zip( 10 k)</a>
Bind data to Repeater Control
<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
If Not IsPostBack Then
Dim DBConn as OleDbConnection
Dim DBCommand As OleDbDataAdapter
Dim DSPageData as New DataSet
DBConn = New OleDbConnection( _
"PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("EmployeeDatabase.mdb;"))
DBCommand = New OleDbDataAdapter _
("Select ID, FirstName " _
& "From Employee " _
& "Order By FirstName", DBConn)
DBCommand.Fill(DSPageData, _
"Employee")
repDepts.DataSource = _
DSPageData.Tables("Employee").DefaultView
repDepts.DataBind()
End If
End Sub
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Creating a Basic Repeater Control</TITLE>
</HEAD>
<Body LEFTMARGIN="40">
<form runat="server">
<BR><BR>
<asp:Label
id="lblMessage"
Font-Size="12pt"
Font-Bold="True"
Font-Name="Lucida Console"
text="Below is a list of all employees"
runat="server"
/>
<BR><BR>
<asp:repeater
id="repDepts"
runat="server"
>
<itemtemplate>
<%# "<B>Department:</B> " _
& DataBinder.Eval(Container.DataItem, "FirstName") _
& " - " _
& DataBinder.Eval(Container.DataItem, "ID")
%>
<BR>
</itemtemplate>
</asp:repeater>
</form>
</BODY>
</HTML>
<A href="http://www.nfex.ru/Code/ASPDownload/EmployeeDatabase.zip">EmployeeDatabase.zip( 10 k)</a>