Bind data from Access database to an ASP:Repeater (VB.net) : Repeater « ASP.net Controls « ASP.NET Tutorial






<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
   sub Page_Load(Sender as Object, e as EventArgs) 
      dim myConnection as new OleDbConnection( _
            "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
            & "DATA SOURCE=" _
            & Server.MapPath("EmployeeDatabase.mdb;"))
      dim myCommand as new OleDbDataAdapter("select * from employee", myConnection)
      dim ds as DataSet = new DataSet()
      myCommand.Fill(ds, "employee")
      Repeater1.DataSource = ds
      Repeater1.DataMember = "employee"
      DataBind()
   end sub
</script>

<html><body>
  <ASP:Repeater id="Repeater1" runat="server" >
     <HeaderTemplate>
        <tr>
           <td width="200"><b>Name</b></td>
           <td width="200"><b>ID</b></td>
        </tr>
     </HeaderTemplate>

     <ItemTemplate>
        <tr>
           <td> <%# Container.DataItem("FirstName") %>&nbsp;
                <%# Container.DataItem("LastName") %>
           </td>
           <td> <%# Container.DataItem("ID") %> </td>
        </tr>
     </ItemTemplate>

     <AlternatingItemTemplate>
        <tr>
           <td> 
              <%# Container.DataItem("FirstName") %>&nbsp;
              <%# Container.DataItem("LastName") %>
           </td>
           <td> 
              <%# Container.DataItem("ID") %> 
           </td>
        </tr>
     </AlternatingItemtemplate>

     <SeparatorTemplate>
        <tr>
           <td colspan="2" align="center">
              - - -
           </td>
        </tr>
     </SeparatorTemplate>
      
     <FooterTemplate>
     </FooterTemplate>
  </ASP:Repeater>
</body></html>








3.24.Repeater
3.24.1.Bind data from Access database to an ASP:Repeater (VB.net)
3.24.2.Repeater with Table