473,787 Members | 2,928 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How and when can I access the controls in the pager row?

I have a FormView control in which I use a PagerTemplate. I am having
trouble accessing the controls in the PagerTemplate. How do I access them,
and in what event should I put the could that accesses them? My current code
is as follows:
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
End Sub

Private Sub fviewPhotoAlbum _ItemCreated(By Val sender As Object, ByVal e
As System.EventArg s) Handles fviewPhotoAlbum .ItemCreated
'Hide unnecessary numeric LinkButtons
For i As Integer = 1 To 10
CType(Me.fviewP hotoAlbum.Botto mPagerRow.Cells (0).FindControl ("lnkPhotoAlbum "
& CStr(i)), LinkButton).Vis ible = (i <= Me.rowcount)
CType(Me.fviewP hotoAlbum.Botto mPagerRow.Cells (0).FindControl ("lnkPhotoAlbum "
& CStr(i)), LinkButton).Tex t = "&nbsp;" & CStr(i) & "&nbsp;"
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
The code that I am not sure what event to put in, or whether is correct, is
the code in the fviewPhotoAlbum _ItemCreated method. I can successfully make
FormView controls with automatically generated Paging controls work, but I
cannot get the PagerTemplate to work. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Jan 26 '07 #1
5 3127
>I have a FormView control in which I use a PagerTemplate. I am having
>trouble accessing the controls in the PagerTemplate. How do I access them,
and in what event should I put the could that accesses them? My current
code is as follows:
fromViewCtrl.Fi ndControl('id_o f_control') should rescue you.

--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujinionline.com
-----------------------------------------
Jan 26 '07 #2
That is what I currently use, but what event(s) is this usable in? On the
following site:

http://msdn2.microsoft.com/en-us/lib...mpagerrow.aspx

It says:

Note:
The BottomPagerRow property is available only after the FormView
control creates the bottom pager row in the ItemCreated event.

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.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Gaurav Vaish (MasterGaurav)" <ga************ *****@nospam.gm ail.comwrote
in message news:eF******** ******@TK2MSFTN GP06.phx.gbl...
I have a FormView control in which I use a PagerTemplate. I am having
trouble accessing the controls in the PagerTemplate. How do I access them,
and in what event should I put the could that accesses them? My current
code is as follows:

fromViewCtrl.Fi ndControl('id_o f_control') should rescue you.

--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujinionline.com
-----------------------------------------


Jan 26 '07 #3
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
-----------------------------------------

Jan 26 '07 #4
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"/>&nbsp;
<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" />&nbsp;
<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 = "&nbsp;" & CStr(i) & "&nbsp;"
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
-----------------------------------------

Jan 26 '07 #5
>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:
Let me munch it over the dinner or tomorrow breakfast... I think I need a
reboot right now.
Should work... because I just tried it out a while ago (bound to DataSet
from Customers in Northwind) :D
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
Jan 27 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2764
by: john_20_28_2000 | last post by:
Does anyone know of anything out there that I can use to dial up a numeric pager, leave a number and then hang up? It is not a "fancy" pager. No message, not text, no nothing. Just a regular old pager. I have looked at the various SMS stuff, but it all goes to text message, etc. Nothing for a regular pager. I have a asp.net page, using c#. User clicks a button that says "Page Me." Somehow the box with the modem dials up the pager...
2
1191
by: Binny | last post by:
I have a datagrid with customized pager in header and footer. Is there a way to find during item created whether its for top or bottom of the Grid. thanks
2
1057
by: Vi | last post by:
Hi, I'm building a screen where I want to allow users to be able to see data one page at a time. The users would view the data by clicking on the Page Nr. The problem is that the number of pages is dynamic, based on how much data the database returns, and I'm having troubles building the list of page numbers. I'm trying to build it using LinkButton controls, but because their number is dynamic, I don't know how to link their handlers to...
0
1095
by: john_20_28_2000 | last post by:
Does anyone know of anything out there that I can use to dial up a numeric pager, leave a number and then hang up? It is not a "fancy" pager. No message, not text, no nothing. Just a regular old pager. I have looked at the various SMS stuff, but it all goes to text message, etc. Nothing for a regular pager. I have a asp.net page. User clicks a button that says "Page Me." Somehow the box with the modem dials up the pager and leaves the...
6
2013
by: Alan Silver | last post by:
Hello, I have been playing with the data grid, which looks very powerful for providing paged views of your data, but I don't like the way the footer bits are displayed when there's only one page. You still get the links, well text really, but they don't mean anything. Can these be switched off? If not, can I at least add some text to the footer? I would like to do this anyway as it's not always immediately obvious that these are...
0
1140
by: Joey | last post by:
Hello, I need to be able to access the linkbuttons that are used for paging inside a datagrid so I can set the style for what eventually becomes the client-side html anchor tags. I have read several posts about using the datagrid's PagerStyle property, but this solution is simply inadequate. This is because I need to be able to apply a CssStyle so that I can get at a:hover and other CSS properties. PagerStyle only applies the selected...
1
1194
by: Sharon | last post by:
Hi all, I'm trying to programmatically render a user control, but problem is, i don't have the control type and i cannot use register directive as the context is not an aspx page. Any ideas, links. Thanks, Sharon.
1
3447
by: SMichal | last post by:
Hi, I need a liitle help with build of my custom pager for gridview...I made this kind of pager..I looks like this: << < 1 2 3 4 5 6 7 8 9 10 > Well...it's no bad but I wannt something like google pager: << < 1 2 3 4... > if user cliks on ... he should see this: << < ...5 6 7 8 ... >
2
1910
by: =?Utf-8?B?QHdpbg==?= | last post by:
Hello There, I need to page a pager whenever an error event takes place in my app. What is the best approach in this? Should I use and modify the SerialPort class to talk to the modem. I hope someone wants to help me or has an example for me Thanks
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.