<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Register tagprefix="ie" namespace="Microsoft.Web.UI.WebControls" assembly="Microsoft.Web.UI.WebControls" %>
<html>
<head>
<title>Using a MultiPage within a Templated Control</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<style type="text/css">
<!--
.fullname {
font:bold italic 13pt arial;
color:navy; margin-bottom:5}
.notes {
background-color:ghostwhite;
padding:10; border:1px inset}
-->
</style>
<script language="C#" runat="server" src="fetchData_sql.cs" />
<script language="C#" runat="server">
void Page_Load ( object src, EventArgs e ) {
if ( ! IsPostBack ) {
lstEmps.SelectedIndex = 0;
lstEmps.DataBind ( );
}
}
void getEmpInfo ( object src, DataListCommandEventArgs e ) {
lstEmps.SelectedIndex = e.Item.ItemIndex;
lstEmps.DataBind ( );
switch ( e.CommandName ) {
case "personalInfo" :
PageView personalInfo = ( PageView ) fvEmp.FindControl ( "personalInfo" );
personalInfo.Activate ( );
break;
case "salesInfo" :
string fullname = ( ( HtmlGenericControl ) fvEmp.FindControl ( "fullname" ) ).InnerText.Trim ( );
string query = "SELECT CompanyName, SUM ( SaleAmount ) AS Sales FROM [Orders Summary] WHERE Salesperson = '" +
fullname + "' GROUP BY CompanyName";
GridView salesGrid = ( GridView ) fvEmp.FindControl ( "salesGrid" );
salesGrid.DataSource = fetchReader ( query );
salesGrid.DataBind ( );
PageView salesInfo = ( PageView ) fvEmp.FindControl ( "salesInfo" );
salesInfo.Activate ( );
break;
}
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc -->
<div class="header"><h2>Using a MultiPage within a Templated Control</h2></div>
<!-- #include virtual="~/shared/viewsrc_top.inc" -->
<hr size=1 width=92%>
<center>
<form runat="server">
<table width=96%>
<tr align="center" valign="top">
<td width=75%>
<asp:formview id="fvEmp" runat="server" width=100%
datasourceid="info">
<itemtemplate>
<div style="padding: 10 10">
<ie:multipage id="empInfo" runat="server" style="font-size: 9pt">
<ie:pageview id="generalInfo">
<table align="center" width=96%>
<tr valign="top">
<td>
<img align="top" border=1 src='<%# Eval ( "photopath",
"/shared/images/{0}" ) %>' /></td>
<td>
<p id="fullname" class="fullname" runat="server">
<%# Eval ( "firstname" ) %> <%# Eval ( "lastname" ) %></p>
<asp:detailsview id="empDetails" runat="server"
width=100% cellpadding=3 font-size=9pt
datasourceid="details"
headertext="Details">
<headerstyle font-bold horizontalalign="center"
backcolor="slategray" forecolor="khaki" />
<rowstyle backcolor="whitesmoke" />
</asp:detailsview>
</td></tr>
</table>
</ie:pageview>
<ie:pageview id="personalInfo">
<div class="fullname" runat="server">
<%# Eval ( "firstname" ) %> <%# Eval ( "lastname" ) %>�s Personal Info</div>
<div class="notes"><%# Eval ( "notes" ) %></div>
</ie:pageview>
<ie:pageview id="salesInfo">
<div class="fullname" runat="server">
<%# Eval ( "firstname" ) %> <%# Eval ( "lastname" ) %>�s Sales Info</div>
<center>
<asp:gridview id="salesGrid" runat="server"
width=90% cellpadding=3 gridlines="horizontal"
font-size="10pt" backcolor="ghostwhite"
autogeneratecolumns=false>
<headerstyle backcolor="steelblue"
forecolor="ivory"
font-bold height=25
horizontalalign="center" />
<columns>
<asp:boundfield headertext="Company"
datafield="CompanyName" />
<asp:boundfield headertext="Sales"
datafield="Sales"
dataformatstring="${0:n}"
itemstyle-horizontalalign="right" />
</columns>
</asp:gridview>
</center>
</ie:pageview>
</ie:multipage>
</div>
</itemtemplate>
</asp:formview>
</td>
<td width=25%>
<asp:datalist id="lstEmps" runat="server"
datasourceid="emps"
datakeyfield="employeeid"
onItemCommand="getEmpInfo">
<selecteditemstyle backcolor="palegoldenrod" />
<itemtemplate>
<table cellpadding=3 style="font-size: 9pt">
<tr>
<td valign="top">
<asp:imagebutton align="top" width=40 border=1 runat="server"
imageurl='<%# Eval ( "photopath", "~/shared/images/{0}" ) %>' />
</td>
<td valign="top">
<asp:linkbutton runat="server"
text='<%# Eval ( "fullname" ) %>'
style="color:darkred" />
<br>
<%# Eval ( "title" ) %>
</td></tr>
</table>
</itemtemplate>
<selecteditemtemplate>
<table cellpadding=3 style="font-size: 9pt">
<tr>
<td valign="top">
<asp:imagebutton align="top" width=40 border=1 runat="server"
imageurl='<%# Eval ( "photopath", "~/shared/images/{0}" ) %>' />
</td>
<td valign="top">
<asp:linkbutton runat="server"
text='<%# Eval ( "fullname" ) %>'
style="color:darkred" />
<br>
<%# Eval ( "title" ) %>
<br>
<asp:linkbutton runat="server"
text="Personal Info"
commandname="personalInfo"
style="font-size:9pt" />
|
<asp:linkbutton runat="server"
text="Sales Info"
commandname="salesInfo"
style="font-size:9pt" />
</td></tr>
</table>
</selecteditemtemplate>
</asp:datalist>
</td></tr>
</table>
</form>
</center>
<asp:sqldatasource id="emps" runat="server"
selectcommand="SELECT EmployeeId, PhotoPath, LastName + ', ' + FirstName As FullName, Title FROM Employees"
connectionstring="<%$ ConnectionStrings:aspnet %>"
datasourcemode="datareader" />
<asp:sqldatasource id="info" runat="server"
selectcommand="SELECT EmployeeId, PhotoPath, LastName, FirstName, Notes FROM Employees"
connectionstring="<%$ ConnectionStrings:aspnet %>"
filterexpression="EmployeeId='{0}'">
<filterparameters>
<asp:controlparameter controlid="lstEmps" propertyname="SelectedValue" />
</filterparameters>
</asp:sqldatasource>
<asp:sqldatasource id="details" runat="server"
selectcommand="SELECT EmployeeId, Title, HireDate, Address +
', ' + City + ', ' + Country AS Address, BirthDate, Extension, HomePhone FROM Employees"
connectionstring="<%$ ConnectionStrings:aspnet %>"
filterexpression="EmployeeId='{0}'">
<filterparameters>
<asp:controlparameter controlid="lstEmps" propertyname="SelectedValue" />
</filterparameters>
</asp:sqldatasource>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>