Paging controls won't show up when using FormView

N

Nathan Sokalski

I have a very simple FormView control, but when I view the page it does not
show the Paging controls, although it does show the data. Here is my code:


<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="FormViewTest.aspx.vb" Inherits="family.FormViewTest" %>
<!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">
</head>
<body>
<form id="form1" runat="server">
<asp:FormView ID="fviewTesting" runat="server" AllowPaging="true"
PagerSettings-Visible="true">
<rowstyle HorizontalAlign="Center"/>
<ItemTemplate>
<asp:Image ID="imgPhoto" runat="server" BorderWidth="0px"
ImageAlign="Middle" ImageUrl='<%#
DataBinder.Eval(Container,"DataItem.filename","images/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","Photo taken on: {0:D}")
%>'/>
</ItemTemplate>
</asp:FormView>
</form>
</body>
</html>


Partial Public Class FormViewTest : Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim photoalbum As New DataTable
Dim dataadapterSelect As New
System.Data.OleDb.OleDbDataAdapter("SELECT * FROM babyphotos ORDER BY
photodate,filename",
System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
dataadapterSelect.Fill(photoalbum)
Me.fviewTesting.DataSource = photoalbum
Me.fviewTesting.DataBind()
End Sub

Private Sub fviewTesting_PageIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles fviewTesting.PageIndexChanged
Dim currfile As String = CType(Me.fviewTesting.DataItem,
DataRowView)("filename").ToString()
Dim photo As System.Drawing.Image =
System.Drawing.Image.FromFile(MapPath("images/photoalbum/" & currfile))
CType(Me.fviewTesting.FindControl("imgPhoto"), Image).Width =
photo.Width
CType(Me.fviewTesting.FindControl("imgPhoto"), Image).Height =
photo.Height
CType(Me.fviewTesting.FindControl("lblPhotoDate"), Label).Text =
CDate(CType(Me.fviewTesting.DataItem,
DataRowView)("photodate")).ToLongDateString()
End Sub
End Class


What am I doing wrong? Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top