<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<title>Binding a DataReader to a DataList 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>DataList</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:sqldatasource id="titles" runat="server"
selectcommand = "SELECT * FROM Titles"
connectionstring = "<%$ ConnectionStrings:aspnet %>"
datasourcemode = "DataReader" />
<asp:datalist id="myList" runat="server"
datasourceid="titles"
width=90% repeatcolumns=2
itemstyle-width=50%>
<itemtemplate>
<table cellpadding=10>
<tr>
<td valign="top">
<a href='<%# Eval ( "title_id", "details_title.aspx?titleid={0}" ) %>'>
<img alt="Click for details" border=0 runat="server"
src='<%# Eval ( "title_id", "~/shared/images/title-{0}.gif" ) %>'
style="box-shadow: 3px 3px 3px gray" /></a>
</td>
<td valign="top">
<b>Title:</b> <a href='<%# Eval ( "title_id", "details_title.aspx?titleid={0}" ) %>'>
<%# Eval ( "title" ) %></a><br>
<b>Category:</b> <%# Eval ( "type" ) %><br>
<b>Publisher ID:</b> <%# Eval ( "pub_id" ) %><br>
<b>Price:</b> <%# Eval ( "Price", "{0:c}" ) %>
</td></tr>
</table>
</itemtemplate>
</asp:datalist>
</form>
</div>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>