<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Register tagprefix="ie" namespace="Microsoft.Web.UI.WebControls" assembly="Microsoft.Web.UI.WebControls" %>
<html>
<head>
<title>MultiPage Navigation Using PageView.Activate</title>
<script language="C#" runat="server" src="~/shared/fetchData_oledb.cs"></script>
<script runat="server">
void Page_Load ( Object source, EventArgs e ) {
if ( ! IsPostBack ) {
gvCities.SelectedIndex = 0;
gvCities.DataBind ( );
getSelected ( null, null );
}
}
void getSelected ( Object src, EventArgs e ) {
DataKey keys = gvCities.SelectedDataKey;
string country = keys [ 0 ].ToString ( );
string state = keys [ 1 ].ToString ( );
string city = keys [ 2 ].ToString ( );
ViewState [ "destination" ] = city + ", " + getCountry ( country );
// bind keys images
string query = "SELECT Top 24 Caption, ThumbnailUrl, Url FROM DestImages WHERE Country = '" + country + ( state != "" ? "' and StateProvince = '" + state : "" ) + "' and City = '" + city + "' ORDER BY Category, Caption";
lstImages.DataSource = fetchReader ( query, "destinations" );
lstImages.DataBind ( );
mpImages.SelectedIndex = 0;
}
void resetSelected ( Object src, EventArgs e ) {
gvCities.SelectedIndex = 0;
gvCities.DataBind ( );
getSelected ( null, null );
}
void showPageZoom ( object src, DataListCommandEventArgs e ) {
string query = "SELECT Caption, Url, Width, Credit, CreditLink, Supplier FROM DestImages WHERE Url = '" + e.CommandArgument + "'";
fvZoom.DataSource = fetchReader ( query, "destinations" );
fvZoom.DataBind ( );
pageZoom.Activate ( );
}
void showPageThumbs ( object src, EventArgs e ) {
pageThumbs.Activate ( );
}
</script>
<script language="C#" runat="server" src="iemultipage.cs"></script>
<script language="JavaScript" src="/shared/css.js"></script>
<style type="text/css">
.titler {
font: bold 13pt "Comic Sans MS", arial, verdana, sans serif; padding: 5 5 5 10;
color:darkslategray }
.caption {
font: bold 10pt "Comic Sans MS", arial, verdana, sans serif; padding: 5 5 5 10;
background:darkslategray; color:palegoldenrod }
</style>
</head>
<body>
<!-- #include virtual="~/shared/top.inc -->
<div class="header"><h2>MultiPage Navigation Using PageView.Activate</h2></div>
<hr size=1 width=92%>
<form runat="server">
<table align="center" cellpadding=10 width=80%>
<tr align="center" valign="top">
<td width=35% align="center">
<table width=96% style="background-color: steelblue; color: beige; font: bold 11pt Comic Sans MS">
<tr height=20pt>
<td>Select Destination</td></tr>
</table>
<asp:gridview id="gvCities" runat="server" width=96%
datasourceid="destinations" datakeynames="Country,StateProvince,City"
autogeneratecolumns=false
showheader=false font-size=10pt
allowpaging pagesize=20
onSelectedIndexChanged="getSelected"
onPageIndexChanged="resetSelected">
<selectedrowstyle backcolor="lightgreen" />
<pagersettings
mode="nextpreviousfirstlast" />
<pagerstyle
backcolor="steelblue" forecolor="beige"
horizontalalign="right" />
<columns>
<asp:templatefield>
<itemtemplate>
<asp:linkbutton runat="server" commandname="select"
text='<%# Eval ( "City" ) %>' />
</itemtemplate>
</asp:templatefield>
</columns>
</asp:gridview>
</td>
<td width=65% align="center">
<ie:multipage id="mpImages" runat="server">
<ie:pageview id="pageThumbs">
<center>
<h3 class="titler">Images of <%= ViewState [ "destination" ] %></h2>
<br>
<asp:datalist id="lstImages" runat="server" width=100%
cellpadding=5 repeatcolumns=6 repeatdirection="horizontal"
onItemDataBound="setImages"
onItemCommand="showPageZoom">
<itemstyle width=120
verticalalign="top" horizontalalign="center" />
<itemtemplate>
<asp:imagebutton id="imgThumb" runat="server"
style="border: 1px inset" width=75 />
</itemtemplate>
</asp:datalist>
</center>
</ie:pageview>
<ie:pageview id="pageZoom">
<center>
<asp:formview id="fvZoom" runat="server"
onDataBound="getZoom"
onItemCommand="showPageThumbs">
<itemtemplate>
<table id="tbllmgZoom" runat="server" align="center" cellspacing=0>
<tr><td align="center"><div class="caption"><asp:label id="lblCaption"
runat="server" /></div></td></tr>
<tr><td align="center"><asp:imagebutton id="imgZoom" runat="server"
style="border: 1px inset" /></td></tr>
<tr><td align="right"><asp:panel id="imgCredits" runat="server"
style="font:bold italic 9pt arial; color:navy; line-height:12pt" /></td></tr>
</table>
</itemtemplate>
</asp:formview>
</center>
</ie:pageview>
</ie:multipage>
</td></tr>
</table>
<asp:sqldatasource id="destinations" runat="server"
ConnectionString="<%$ ConnectionStrings:dests %>"
ProviderName="System.Data.OleDb"
selectcommand="SELECT Country, StateProvince, City FROM PopularDestinations WHERE Country+City in ( SELECT DISTINCT Country+City FROM DestImages ) ORDER BY City" />
</form>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>