473,790 Members | 3,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

add link to existing Gridview 2.0 default pagertemplate

When I try and edit the PagerTemplate it erases the default paging controls.
Is there a way to add a link control to this region while still keeping the
default paging controls?

Thanks.
Mar 20 '06 #1
3 15720
If you are looking to add a static control (that does not need to raise a
server-side event) then consume the RowCreated event instead of overwritting
the PagerTemplate, e.g.

void GridView1_RowCr eated(object sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType= =DataControlRow Type.Pager)
{
HyperLink hlink= new HyperLink();
hlink.NavigateU rl="AnotherPage .aspx";
hlink.Text="Pag eTitle";
//notice that the pager template renders one cell in which
//there is an HTMLTable
e.Row.Cells[0].Controls.Add(h link);
}
}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
When I try and edit the PagerTemplate it erases the default paging controls.
Is there a way to add a link control to this region while still keeping the
default paging controls?

Thanks.

Mar 20 '06 #2
Wow! perfectomundo! do you sometimes feel you know TOO much?

Thanks.

"Phillip Williams" wrote:
If you are looking to add a static control (that does not need to raise a
server-side event) then consume the RowCreated event instead of overwritting
the PagerTemplate, e.g.

void GridView1_RowCr eated(object sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType= =DataControlRow Type.Pager)
{
HyperLink hlink= new HyperLink();
hlink.NavigateU rl="AnotherPage .aspx";
hlink.Text="Pag eTitle";
//notice that the pager template renders one cell in which
//there is an HTMLTable
e.Row.Cells[0].Controls.Add(h link);
}
}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
When I try and edit the PagerTemplate it erases the default paging controls.
Is there a way to add a link control to this region while still keeping the
default paging controls?

Thanks.

Mar 20 '06 #3
This didn't work for me, nothing appears in the HTML. I also tried:

protected void VanListGridView _PreRender( object sender, EventArgs e ) {
GridView grid = ( sender as GridView );

if ( grid != null ) {
GridViewRow pagerRow = grid.BottomPage rRow;

if ( pagerRow != null && pagerRow.Visibl e ) {
Table pagerTable = ( pagerRow.Cells[0].Controls[0] as Table );
HyperLink hlink = new HyperLink();
hlink.NavigateU rl = "VanListDetail. aspx";
hlink.Text = "New...";
hlink.CssClass = "waLink";
//pagerRow.Cells[0].Controls.AddAt ( 0, hlink );
pagerRow.Cells[0].Controls.Add( hlink );

}
}
}

which also did nothing. I would be willing to use a PagerTemplate but would
like to keep the automagic page numbers links that are generated by the
GridView.

Any suggestions?

"Phillip Williams" wrote:
If you are looking to add a static control (that does not need to raise a
server-side event) then consume the RowCreated event instead of overwritting
the PagerTemplate, e.g.

void GridView1_RowCr eated(object sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType= =DataControlRow Type.Pager)
{
HyperLink hlink= new HyperLink();
hlink.NavigateU rl="AnotherPage .aspx";
hlink.Text="Pag eTitle";
//notice that the pager template renders one cell in which
//there is an HTMLTable
e.Row.Cells[0].Controls.Add(h link);
}
}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
When I try and edit the PagerTemplate it erases the default paging controls.
Is there a way to add a link control to this region while still keeping the
default paging controls?

Thanks.

Mar 28 '06 #4

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

Similar topics

3
8516
by: clintonG | last post by:
Briefly stated, my problem is accessing and 'setting' properties of a label control declared in the template of another control noting that the other control is an instance of the beta 2 DetailsView control which supports a PagingTemplate. Somewhere I grabbed some declarations for a PagerTemplate to display paging as: <<First < Prev Next> Last>>
2
2613
by: Nathan Sokalski | last post by:
I am trying to create a FormView controls in which I access and modify the the controls in the PagerTemplate programmatically. However, I continue to recieve the following error: Object reference not set to an instance of an object. I am attempting to access the controls in my PagerTemplate using the following code: CType(Me.fviewPhotoAlbum.FindControl("lnkPhotoAlbum"), LinkButton)
5
1990
by: Cindy Lee | last post by:
I want to have a button to view top 5 and toggle to view all on my gridview. Can this be done using paging? I don't want to show page 1, 2, 3. Just the top 5 or all. Or am I going to have to postback and change my query? If I do that I will also lose my current sorting. Any suggestions?
0
2439
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from a data view (which in turn is loaded from a manually setup DataTable for testing purposes). One of the columns in the grid is a checkbox that's tied to an event handler that'll change the .Visible property of a column with a text box. That text...
5
3008
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item list that corresponds with the number of pages, but I am unable to wire up the Selected Index Changed event. Auto PostBack is set to true and the page is posting back when the DDL is selected / chaged, but the event is never being called. Any...
1
2706
by: mark4asp | last post by:
I moved a page to another web-site and now it's broke! I had 5 pages in their own web-site. These pages have now been moved to another web-site. Everything is fine except that one of the pages, which I had trouble with in the past (i.e. same problem), is now partly broke. The paging no longer fully works in the gridview. The gvAwarded_RowDataBound code works to load the ddlPager with the correct number of pages.
0
2271
by: Stan SR | last post by:
Hi, I need to customize a pargertemplate with these items a arrow to go back to the 1rst page a arrow for the previous page a dropdownlist with the page indexes a arrow for the new page a arrow for the last page. The dropdownlist function is okay, but I m blocked with the arrows
4
11900
by: Jeff | last post by:
Hi, I have a ASP.NET 2.0 Web Application. Many of the pages use the ASP.NET GridView with paging and sorting. One of the columns of this Gridview is a template column (LinkButton). The data being retrieved and showed in this GridView produce more than one page of data. A given user clicks on the first row hyper link on the Grid on the first page, then the first row hyper link color changes to look as "visited". Then the user navigates to...
4
8367
by: marksommerville | last post by:
I have a few questions regarding accessing a gridview control from Javascript which I would really appreciate some help with. 1. The gridview contains a column of checkboxes as a template field. I have onclick Javascript on the checkbox but can't figure out how to determine the row number of the checkbox that was clicked. 2. How do I access a control within the gridview's pagertemplate? The pagertemplate contains a 1 row table with a...
0
9666
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
9512
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
10419
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
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10147
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9023
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
7531
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
5424
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...
1
4100
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.