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="ind extest.aspx.vb" Inherits="famil y.indextest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:FormView ID="fviewPhotoA lbum" runat="server" AllowPaging="Tr ue"
HorizontalAlign ="Center" Visible="false" >
<PagerSetting s NextPageImageUr l="images/NextBtn.gif"
PreviousPageIma geUrl="images/PrevBtn.gif" Mode="NextPrevi ous"
Position="Botto m"/>
<RowStyle HorizontalAlign ="Center"/>
<ItemTemplate >
<asp:Image ID="imgPhoto" runat="server" BorderWidth="0p x"
ImageAlign="Mid dle" ImageUrl='<%#
DataBinder.Eval (Container,"Dat aItem.filename" ,"images/photoalbum/{0}")
%>'/><br/>
<asp:Label ID="lblPhotoCap tion" runat="server"
AssociatedContr olID="imgPhoto" Text='<%#
DataBinder.Eval (Container,"Dat aItem.caption") %>'/><br/>
<asp:Label ID="lblPhotoDat e" runat="server"
AssociatedContr olID="imgPhoto" Text='<%#
DataBinder.Eval (Container,"Dat aItem.photodate ","Photo taken on: {0:D}")
%>'/>
</ItemTemplate>
<PagerTemplat e>
<asp:ImageButto n ID="imgPrevious " runat="server"
AlternateText=" Previous Photo" BorderWidth="0p x" CausesValidatio n="False"
CommandArgument ="Prev" CommandName="Pa ge" Height="35px"
ImageUrl="image s/PrevBtn.gif" Width="35px"/>
<asp:LinkButt on ID="lnkPhotoAlb um1" runat="server"
CausesValidatio n="false" CommandName="Pa ge" Text="A" />
<asp:LinkButt on ID="lnkPhotoAlb um2" runat="server"
CausesValidatio n="false" CommandName="Pa ge" Text="B" />
<asp:LinkButt on ID="lnkPhotoAlb um3" runat="server"
CausesValidatio n="false" CommandName="Pa ge" Text="C" />
<asp:LinkButt on ID="lnkPhotoAlb um4" runat="server"
CausesValidatio n="false" CommandName="Pa ge" Text="D" />
<asp:LinkButt on ID="lnkPhotoAlb um5" runat="server"
CausesValidatio n="false" CommandName="Pa ge" Text="E" />
<asp:LinkButt on ID="lnkPhotoAlb um6" runat="server"
CausesValidatio n="false" CommandName="Pa ge" Text="F" />
<asp:LinkButt on ID="lnkPhotoAlb um7" runat="server"
CausesValidatio n="false" CommandName="Pa ge" Text="G" />
<asp:LinkButt on ID="lnkPhotoAlb um8" runat="server"
CausesValidatio n="false" CommandName="Pa ge" Text="H" />
<asp:LinkButt on ID="lnkPhotoAlb um9" runat="server"
CausesValidatio n="false" CommandName="Pa ge" Text="I" />
<asp:LinkButt on ID="lnkPhotoAlb um10" runat="server"
CausesValidatio n="false" CommandName="Pa ge" Text="J" />
<asp:ImageButto n ID="imgNext" runat="server" AlternateText=" Next Photo"
BorderWidth="0p x" CausesValidatio n="False" CommandArgument ="Next"
CommandName="Pa ge" Height="35px" ImageUrl="image s/NextBtn.gif"
Width="35px"/>
</PagerTemplate>
</asp:FormView>
</form>
</body>
</html>
indextest.aspx. vb:
Partial Public Class indextest : Inherits System.Web.UI.P age
Private rowcount As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
If Not Me.IsPostBack Then Me.Refresh()
End Sub
Private Sub Refresh()
'Bind data
Dim photoalbum As New DataTable
Dim dataadapterSele ct As New
System.Data.Ole Db.OleDbDataAda pter("SELECT * FROM babyphotos ORDER BY
photodate,filen ame",
System.Configur ation.Configura tionManager.App Settings("conne ctionstring"))
dataadapterSele ct.Fill(photoal bum)
Me.fviewPhotoAl bum.DataSource = photoalbum
Me.fviewPhotoAl bum.DataBind()
Me.rowcount = photoalbum.Rows .Count
'Response.Write (Me.rowcount & ControlChars.Ne wLine)
End Sub
Private Sub fviewPhotoAlbum _DataBound(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles fviewPhotoAlbum .DataBound
'Hide unnecessary numeric LinkButtons
For i As Integer = 1 To 10
CType(Me.fviewP hotoAlbum.Botto mPagerRow.FindC ontrol("lnkPhot oAlbum"
& CStr(i)), LinkButton).Vis ible = (i <= Me.rowcount)
CType(Me.fviewP hotoAlbum.Botto mPagerRow.FindC ontrol("lnkPhot oAlbum"
& CStr(i)), LinkButton).Tex t = " " & CStr(i) & " "
Next
End Sub
Private Sub fviewPhotoAlbum _PageIndexChang ed(ByVal sender As Object,
ByVal e As System.EventArg s) Handles fviewPhotoAlbum .PageIndexChang ed
Dim currfile As String = CType(Me.fviewP hotoAlbum.DataI tem,
DataRowView)("f ilename").ToStr ing()
Dim photo As System.Drawing. Image =
System.Drawing. Image.FromFile( MapPath("images/photoalbum/" & currfile))
CType(Me.fviewP hotoAlbum.FindC ontrol("imgPhot o"), Image).Width =
photo.Width
CType(Me.fviewP hotoAlbum.FindC ontrol("imgPhot o"), Image).Height =
photo.Height
End Sub
Private Sub fviewPhotoAlbum _PageIndexChang ing(ByVal sender As Object,
ByVal e As System.Web.UI.W ebControls.Form ViewPageEventAr gs) Handles
fviewPhotoAlbum .PageIndexChang ing
Me.fviewPhotoAl bum.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********@hotm ail.com http://www.nathansokalski.com/
"Gaurav Vaish (MasterGaurav)" <ga************ *****@nospam.gm ail.comwrote
in message news:%2******** **********@TK2M SFTNGP03.phx.gb l...
>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.FindContr ol('lnkPhotoAlb um')
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
-----------------------------------------