<html>
<title>Basic DetailsView Example</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="C#" runat="server">
void Page_Load ( Object src, EventArgs e ) {
// initialize selection
if ( !IsPostBack ) customersGrid.SelectedIndex = 0;
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc -->
<div class="header"><h2>Basic DetailsView Example</h2></div>
<!-- #include virtual="~/shared/viewsrc_top.inc" -->
<hr size=1 width=92%>
<div align="center">
<form runat="server">
<table width=92% align="center" cellpadding=5>
<col width=50% align="center">
<col width=50% align="center">
<tr>
<td>
<asp:gridview id="customersGrid" runat="server"
width=96% cellpadding=3
datasourceid="customers"
datakeynames="CustomerID"
autogeneratecolumns=false>
<columns>
<asp:commandfield showselectbutton />
<asp:boundfield datafield="ContactName" headertext="ContactName" />
<asp:boundfield datafield="CompanyName" headertext="CompanyName" />
</columns>
</asp:gridview>
</td>
<td valign="top">
<asp:detailsview id="customerDetails" runat="server"
width=96% cellpadding=3
datasourceid="details"
headertext="Contact Details"
datakeynames="CustomerID">
<headerstyle font-bold
horizontalalign="center" />
</asp:detailsview>
</td>
</tr>
</table>
<asp:sqldatasource id="details" runat="server"
SelectCommand="SELECT * FROM Customers WHERE CustomerID = @CustomerID"
connectionstring="<%$ ConnectionStrings:aspnet %>">
<selectparameters>
<asp:controlparameter controlid="customersGrid" name="CustomerID"
propertyname="SelectedValue" />
</selectparameters>
</asp:sqldatasource>
<asp:sqldatasource id="customers" runat="server"
SelectCommand="SELECT CompanyName, ContactName, CustomerID FROM Customers"
connectionstring="<%$ ConnectionStrings:aspnet %>" />
</form>
</div>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>