I tried that, and just like the other things I tried, it just gives me an
empty browser window. Here is my exact code from my files:
indextest.aspx:
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="indextest.aspx.vb" Inherits="family.indextest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:FormView ID="fviewPhotoAlbum" runat="server" AllowPaging="True"
HorizontalAlign="Center" Visible="false">
<PagerSettings NextPageImageUrl="images/NextBtn.gif"
PreviousPageImageUrl="images/PrevBtn.gif" Mode="NextPrevious"
Position="Bottom"/>
<RowStyle HorizontalAlign="Center"/>
<ItemTemplate>
<asp:Image ID="imgPhoto" runat="server" BorderWidth="0px"
ImageAlign="Middle" ImageUrl='<%#
DataBinder.Eval(Container,"DataItem.filename","ima ges/photoalbum/{0}")
%>'/><br/>
<asp:Label ID="lblPhotoCaption" runat="server"
AssociatedControlID="imgPhoto" Text='<%#
DataBinder.Eval(Container,"DataItem.caption") %>'/><br/>
<asp:Label ID="lblPhotoDate" runat="server"
AssociatedControlID="imgPhoto" Text='<%#
DataBinder.Eval(Container,"DataItem.photodate","Ph oto taken on: {0:D}")
%>'/>
</ItemTemplate>
<PagerTemplate>
<asp:ImageButton ID="imgPrevious" runat="server"
AlternateText="Previous Photo" BorderWidth="0px" CausesValidation="False"
CommandArgument="Prev" CommandName="Page" Height="35px"
ImageUrl="images/PrevBtn.gif" Width="35px"/>
<asp:LinkButton ID="lnkPhotoAlbum1" runat="server"
CausesValidation="false" CommandName="Page" Text="A" />
<asp:LinkButton ID="lnkPhotoAlbum2" runat="server"
CausesValidation="false" CommandName="Page" Text="B" />
<asp:LinkButton ID="lnkPhotoAlbum3" runat="server"
CausesValidation="false" CommandName="Page" Text="C" />
<asp:LinkButton ID="lnkPhotoAlbum4" runat="server"
CausesValidation="false" CommandName="Page" Text="D" />
<asp:LinkButton ID="lnkPhotoAlbum5" runat="server"
CausesValidation="false" CommandName="Page" Text="E" />
<asp:LinkButton ID="lnkPhotoAlbum6" runat="server"
CausesValidation="false" CommandName="Page" Text="F" />
<asp:LinkButton ID="lnkPhotoAlbum7" runat="server"
CausesValidation="false" CommandName="Page" Text="G" />
<asp:LinkButton ID="lnkPhotoAlbum8" runat="server"
CausesValidation="false" CommandName="Page" Text="H" />
<asp:LinkButton ID="lnkPhotoAlbum9" runat="server"
CausesValidation="false" CommandName="Page" Text="I" />
<asp:LinkButton ID="lnkPhotoAlbum10" runat="server"
CausesValidation="false" CommandName="Page" Text="J" />
<asp:ImageButton ID="imgNext" runat="server" AlternateText="Next Photo"
BorderWidth="0px" CausesValidation="False" CommandArgument="Next"
CommandName="Page" Height="35px" ImageUrl="images/NextBtn.gif"
Width="35px"/>
</PagerTemplate>
</asp:FormView>
</form>
</body>
</html>
indextest.aspx.vb:
Partial Public Class indextest : Inherits System.Web.UI.Page
Private rowcount As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not Me.IsPostBack Then Me.Refresh()
End Sub
Private Sub Refresh()
'Bind data
Dim photoalbum As New DataTable
Dim dataadapterSelect As New
System.Data.OleDb.OleDbDataAdapter("SELECT * FROM babyphotos ORDER BY
photodate,filename",
System.Configuration.ConfigurationManager.AppSetti ngs("connectionstring"))
dataadapterSelect.Fill(photoalbum)
Me.fviewPhotoAlbum.DataSource = photoalbum
Me.fviewPhotoAlbum.DataBind()
Me.rowcount = photoalbum.Rows.Count
'Response.Write(Me.rowcount & ControlChars.NewLine)
End Sub
Private Sub fviewPhotoAlbum_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs) Handles fviewPhotoAlbum.DataBound
'Hide unnecessary numeric LinkButtons
For i As Integer = 1 To 10
CType(Me.fviewPhotoAlbum.BottomPagerRow.FindContro l("lnkPhotoAlbum"
& CStr(i)), LinkButton).Visible = (i <= Me.rowcount)
CType(Me.fviewPhotoAlbum.BottomPagerRow.FindContro l("lnkPhotoAlbum"
& CStr(i)), LinkButton).Text = " " & CStr(i) & " "
Next
End Sub
Private Sub fviewPhotoAlbum_PageIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles fviewPhotoAlbum.PageIndexChanged
Dim currfile As String = CType(Me.fviewPhotoAlbum.DataItem,
DataRowView)("filename").ToString()
Dim photo As System.Drawing.Image =
System.Drawing.Image.FromFile(MapPath("images/photoalbum/" & currfile))
CType(Me.fviewPhotoAlbum.FindControl("imgPhoto"), Image).Width =
photo.Width
CType(Me.fviewPhotoAlbum.FindControl("imgPhoto"), Image).Height =
photo.Height
End Sub
Private Sub fviewPhotoAlbum_PageIndexChanging(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewPageEventArgs) Handles
fviewPhotoAlbum.PageIndexChanging
Me.fviewPhotoAlbum.PageIndex = e.NewPageIndex
Me.Refresh()
End Sub
End Class
You will notice that the code in my DataBound eventhandler attempts to set
the Visible property of some of the controls in the PagerTemplate. To make
sure this was not the reason for the empty browser window (although the
ItemTemplate and the other PagerTemplate controls should show anyway), I
tried it with that line commented out and with the whole DataBound event
commented out, but I still receive an empty browser window. The
Response.Write() at the end of the Refresh() method was a check to make sure
my DataSource was not empty, and it wasn't (the Response.Write() output a
3). Why can't I get this thing to work? I don't have any problems when I
don't use the PagerTemplate. Thanks.
--
Nathan Sokalski
nj********@hotmail.com http://www.nathansokalski.com/
"Gaurav Vaish (MasterGaurav)" <ga*****************@nospam.gmail.comwrote
in message news:%2******************@TK2MSFTNGP03.phx.gbl...
>I feel like I have tried every event possible, but I either receive an
error or nothing. Keep in mind that I am trying to access the controls in
the PagerTemplate, not the ItemTemplate. Thanks.
Handle the event DataBound
fviewPhotoAlbum_DataBound(...)
Dim pager as FormViewRow = fviewPhotoAlbum.BottomPagerRow
Dim myControl as Control = pager.FindControl('lnkPhotoAlbum')
Dim btn as LinkButton = CType(myControl, LinkButton)
End Sub
HTH
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujinionline.com
-----------------------------------------