<html>
<head>
<title>Master/Detail Example Using Views: Author Titles</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="C#" runat="server">
void Page_Load ( object src, EventArgs e ) {
if ( !IsPostBack ) {
gvAuthors.SelectedIndex = 0;
}
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc -->
<div class="header"><h2>Master/Details Example Using Views: <b>Author Titles</b></h2></div>
<!-- #include virtual="~/shared/viewsrc_top.inc" -->
<hr size=1 width=92%>
<center>
<form runat="server">
<asp:sqldatasource id="authors" runat="server"
selectcommand="SELECT au_id, au_lname, au_fname, Address, City, State FROM Authors ORDER BY au_lname"
connectionstring="<%$ ConnectionStrings:aspnet %>" />
<asp:gridview id="gvAuthors" runat="server"
datasourceid="authors" datakeynames="au_id"
autogeneratecolumns=false
width="80%" font-size=10pt cellpadding=8
forecolor="black" backcolor="white" gridlines="none"
allowpaging="true" pagesize="8">
<headerstyle font-bold="true" forecolor="white" backcolor="#4a3c8c" />
<selectedrowstyle forecolor="white" backcolor="#9471de" />
<pagersettings mode="nextprevious"
nextpagetext="Next" previouspagetext="Back"
position = "top" />
<pagerstyle horizontalalign="right"
backcolor="steelblue"
forecolor="beige" />
<rowstyle backcolor="#dedfde" />
<columns>
<asp:buttonfield headertext="Author ID"
datatextfield="au_id"
commandname="Select" />
<asp:boundfield headertext="Last Name"
datafield="au_lname" />
<asp:boundfield headertext="First Name"
datafield="au_fname" />
<asp:boundfield headertext="Address"
datafield="Address" />
<asp:boundfield headertext="City"
datafield="City" />
<asp:boundfield headertext="State"
datafield="State" />
</columns>
</asp:gridview>
<p><!-- --></p>
<asp:sqldatasource id="titles" runat="server"
selectcommand="SELECT * FROM AuthorTitles"
filterexpression="au_id='{0}'"
connectionstring="<%$ ConnectionStrings:aspnet %>">
<filterparameters>
<asp:controlparameter controlid="gvAuthors"
propertyname="SelectedValue" />
</filterparameters>
</asp:sqldatasource>
<asp:datalist id="lstTitles" runat="server"
datasourceid="titles"
width=50% enableviewstate=false>
<itemtemplate>
<div class="header"><h2 style="color:maroon"><%# Eval ( "title" ) %></h2></div>
<table cellpadding=10>
<tr>
<td valign="top">
<img align="top" runat="server"
src='<%# Eval ( "title_id", "~/shared/images/title-{0}.gif" ) %>'
style="box-shadow: 3px 3px 6px gray" />
</td>
<td valign="top">
<table>
<tr bgcolor="beige">
<td colspan=2 style="padding:10; border:2px inset"><%# Eval ( "notes" ) %></td>
</tr>
<tr><td><!-- spacer --></td></tr>
<tr style="font-size:11pt">
<td width=40%>
<b>Category:</b> <%# Eval ( "type" ) %><br>
<b>Publisher ID:</b> <%# Eval ( "pub_id" ) %><br>
<b>Price:</b> <%# Eval ( "price", "{0:c}" ) %>
</td>
<td width=60%>
<b>Title ID:</b> <%# Eval ( "title_id" ) %><br>
<b>Published:</b> <%# Eval ( "pubdate", "{0:d}" ) %><br>
<b>Year-To-Date Sales:</b> <%# Eval ( "ytd_sales", "{0:c}" ) %>
</td>
</tr>
</table>
</td></tr>
</table>
</itemtemplate>
</asp:datalist>
</form>
</center>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>