473,473 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Create 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 15706
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_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType==DataControlRowType.Pager)
{
HyperLink hlink= new HyperLink();
hlink.NavigateUrl="AnotherPage.aspx";
hlink.Text="PageTitle";
//notice that the pager template renders one cell in which
//there is an HTMLTable
e.Row.Cells[0].Controls.Add(hlink);
}
}
--
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_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType==DataControlRowType.Pager)
{
HyperLink hlink= new HyperLink();
hlink.NavigateUrl="AnotherPage.aspx";
hlink.Text="PageTitle";
//notice that the pager template renders one cell in which
//there is an HTMLTable
e.Row.Cells[0].Controls.Add(hlink);
}
}
--
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.BottomPagerRow;

if ( pagerRow != null && pagerRow.Visible ) {
Table pagerTable = ( pagerRow.Cells[0].Controls[0] as Table );
HyperLink hlink = new HyperLink();
hlink.NavigateUrl = "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_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType==DataControlRowType.Pager)
{
HyperLink hlink= new HyperLink();
hlink.NavigateUrl="AnotherPage.aspx";
hlink.Text="PageTitle";
//notice that the pager template renders one cell in which
//there is an HTMLTable
e.Row.Cells[0].Controls.Add(hlink);
}
}
--
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
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...
2
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...
5
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...
0
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...
5
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...
1
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,...
0
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...
4
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...
4
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....
0
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,...
0
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...
1
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...
0
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,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.