<html>
<head>
<title>GridView PagerSettings, PagerStyle Example</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="C#" runat="server">
void setPager ( Object src, EventArgs e ) {
plansGrid.PagerSettings.Mode = ( chkNumbers.Checked ) ?
PagerButtons.Numeric : PagerButtons.NextPrevious;
plansGrid.PagerSettings.Position = ( chkTop.Checked ) ?
PagerPosition.Top : PagerPosition.Bottom;
plansGrid.PagerSettings.Visible = ( !chkHide.Checked );
plansGrid.DataBind ( );
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc" -->
<div class="header"><h2>GridView <span class="hilite">PagerSettings</span>, <span class="hilite">PagerStyle</span> Example</h2></div>
<hr size=1 width=92%>
<div align="center">
<form runat="server">
<table cellpadding=5 width=100%>
<tr style="font-size:8pt">
<td>Plan Type <asp:dropdownlist id="typesSelect" runat="server"
datasourceid="planTypes" datatextfield="Type" autopostback /></td>
<td><b><asp:label id="lblTracker" runat="server" /></b></td>
<td align="right">
<asp:checkbox id="chkNumbers" runat="server"
title="Mode Property"
text="Numeric buttons"
autopostback
onCheckedChanged="setPager" />
<asp:checkbox id="chkTop" runat="server"
title="Position Property"
text="Pager on Top"
autopostback checked
onCheckedChanged="setPager" />
<asp:checkbox id="chkHide" runat="server"
title="Visibility Property"
text="Hide Pager"
autopostback
onCheckedChanged="setPager" />
</td></tr>
</table>
<asp:gridview id="plansGrid" runat="server"
datasourceid="plans"
width=90% cellpadding=5
font-size="9pt"
gridlines="horizontal"
showheader=false
autogeneratecolumns=false
allowpaging pagesize=3
rowstyle-verticalalign="top">
<pagersettings
mode="nextprevious"
nextpagetext="Next" previouspagetext="Back"
position="top"
pagebuttoncount=10 />
<pagerstyle
backcolor="steelblue" forecolor="beige"
horizontalalign="right" />
<columns>
<asp:boundfield
datafield="Design" />
<asp:boundfield
datafield="Model" />
<asp:boundfield
datafield="Description" />
<asp:boundfield
datafield="PlanID"
itemstyle-horizontalalign="right" />
<asp:templatefield>
<itemtemplate>
<asp:hyperlink runat="server"
navigateurl='<%# Eval ( "PlanID", "plan_details.aspx?id={0}" ) %>'
imageurl='<%# Eval ( "PlanID", "~/shared/images/plans/thumbs/{0}.jpg" ) %>'
tooltip='<%# Eval ( "Model" ) %>' />
</itemtemplate>
</asp:templatefield>
</columns>
</asp:gridview>
<asp:accessdatasource id="planTypes" runat="server"
datafile="~/app_data/plans.mdb"
selectcommand="SELECT DISTINCT Type FROM Plans WHERE not Type=''"
datasourcemode="DataReader" />
<asp:accessdatasource id="plans" runat="server"
datafile="~/app_data/plans.mdb"
selectcommand="SELECT Type, Design, Model, Description, PlanId FROM Plans"
filterexpression="Type='{0}'">
<filterparameters>
<asp:controlparameter controlid="typesSelect" propertyname="SelectedValue" />
</filterparameters>
</asp:accessdatasource>
</form>
</div>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>