Bind data to Repeater Control : Repeater « ADO.net Database « ASP.Net






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>
           
       








EmployeeDatabase.zip( 10 k)

Related examples in the same category

1.Bind data to asp:Repeater with itemtemplate, alternatingitemtemplate, separatortemplate and footertemplate