<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<title>Binding a DataReader to a Repeater Using DataSourceID</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<body>
<!-- #include virtual="~/shared/top.inc -->
<div class="header"><h2>Binding a <b>DataReader</b> to a <b>Repeater</b> Using <b>DataSourceID</b></h2></div>
<!-- #include virtual="~/shared/viewsrc_top.inc" -->
<hr size=1 width=92%>
<div align="center">
<form runat="server">
<asp:accessdatasource id="products" runat="server"
datafile="~/app_data/dbtutor.mdb"
selectcommand="SELECT * FROM Products"
datasourcemode="DataReader" />
<asp:repeater id="myRepeater" runat="server"
datasourceid="products">
<headertemplate>
<table width="92%" cellspacing=1 cellpadding=5 style="font:10pt verdana">
<tr style="background:brown; color:snow; height:25pt">
<th>ProductType</th>
<th>ProductCode</th>
<th>ProductName</th>
<th>ProductDescription</th>
<th>UnitPrice</th></tr>
</headertemplate>
<itemtemplate>
<tr>
<td><%# Eval ( "ProductType" ) %></td>
<td><a href='details_prod.aspx?id=<%# Eval ( "ProductCode" ) %>'>
<%# Eval ( "ProductCode" ) %></a></td>
<td><%# Eval ( "ProductName" ) %></td>
<td><%# Eval ( "ProductDescription" ) %></td>
<td align="right"><%# Eval ( "UnitPrice", "{0:c}" ) %></td></tr>
</itemtemplate>
<alternatingitemtemplate>
<tr style="background-color:beige">
<td><%# Eval ( "ProductType" ) %></td>
<td><a href='details_prod.aspx?id=<%# Eval ( "ProductCode" ) %>'>
<%# Eval ( "ProductCode" ) %></a></td>
<td><%# Eval ( "ProductName" ) %></td>
<td><%# Eval ( "ProductDescription" ) %></td>
<td align="right"><%# Eval ( "UnitPrice", "{0:c}" ) %></td></tr>
</alternatingitemtemplate>
<footertemplate>
</table>
</footertemplate>
</asp:repeater>
</form>
</div>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>