473,795 Members | 2,974 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic PagerTemplate

Having trouble creating a dynamic pagertemplate. I want it like this
"Prev 1 2 3 4 Next". The numerically portion being the dynamic part
based on the record count.

I can generate it, but can't get any events to fire.

Is it possible to do? I've tried creating them int he RowCreated
event, DataBound and my own PagerTemplate, but nothing seems to work.
Here is one snippet that I've tried. It causes a postback, but it
isn't handled by the gridview.

protected void gvSearchResults _RowCreated(obj ect sender,
GridViewRowEven tArgs e)
{
if( e.Row.RowType == DataControlRowT ype.Pager)
{
// Get the pager row.
GridViewRow pagerRow = e.Row;

// Get the pager row.
Panel pagesPanel =
(Panel)pagerRow .FindControl("P agesPanel");

//Panel pagesPanel = pagesPanel;
LinkButton myButton = new LinkButton();
myButton.Text = "Prev";
myButton.Comman dName = "Page";
myButton.Comman dArgument = "Prev";
myButton.ID = "PrevPage";
pagesPanel.Cont rols.Add(myButt on);

for (int i = 1; i < ((GridView)send er).PageCount + 1; i++)
{
myButton = new LinkButton();
myButton.Text = String.Format(" {0}&nbsp;", i);
myButton.Comman dName = "Page";
myButton.Comman dArgument = i.ToString();
myButton.ID = "Page" + i;
pagesPanel.Cont rols.Add(myButt on);
}

myButton = new LinkButton();
myButton.Text = "Next";
myButton.Comman dName = "Page";
myButton.Comman dArgument = "Next";
myButton.ID = "NextPage";
pagesPanel.Cont rols.Add(myButt on);
}
}

Jan 24 '07 #1
4 7632
Hi,
Take a look at this article....
http://kikosantos.wordpress.com/2006...dview-control/

Thanks

Masudur
www.kaz.com.bd
http://munnacs.blogspot.com/

On Jan 24, 11:28 am, "marty" <m...@jump-technologies.co mwrote:
Having trouble creating a dynamic pagertemplate. I want it like this
"Prev 1 2 3 4 Next". The numerically portion being the dynamic part
based on the record count.

I can generate it, but can't get any events to fire.

Is it possible to do? I've tried creating them int he RowCreated
event, DataBound and my own PagerTemplate, but nothing seems to work.

Here is one snippet that I've tried. It causes a postback, but it
isn't handled by the gridview.

protected void gvSearchResults _RowCreated(obj ect sender,
GridViewRowEven tArgs e)
{
if( e.Row.RowType == DataControlRowT ype.Pager)
{
// Get the pager row.
GridViewRow pagerRow = e.Row;

// Get the pager row.
Panel pagesPanel =
(Panel)pagerRow .FindControl("P agesPanel");

//Panel pagesPanel = pagesPanel;
LinkButton myButton = new LinkButton();
myButton.Text = "Prev";
myButton.Comman dName = "Page";
myButton.Comman dArgument = "Prev";
myButton.ID = "PrevPage";
pagesPanel.Cont rols.Add(myButt on);

for (int i = 1; i < ((GridView)send er).PageCount + 1; i++)
{
myButton = new LinkButton();
myButton.Text = String.Format(" {0}&nbsp;", i);
myButton.Comman dName = "Page";
myButton.Comman dArgument = i.ToString();
myButton.ID = "Page" + i;
pagesPanel.Cont rols.Add(myButt on);
}

myButton = new LinkButton();
myButton.Text = "Next";
myButton.Comman dName = "Page";
myButton.Comman dArgument = "Next";
myButton.ID = "NextPage";
pagesPanel.Cont rols.Add(myButt on);
}
}
Jan 24 '07 #2
I have. He's using a dropdown list. Not the same thing as adding
control dynamically.

On Jan 24, 3:30 am, "Masudur" <munn...@gmail. comwrote:
Hi,

Take a look at this article....http://kikosantos.wordpress.com/2006...g-in-gridview-...

Thanks

Masudurwww.kaz. com.bdhttp://munnacs.blogspo t.com/

On Jan 24, 11:28 am, "marty" <m...@jump-technologies.co mwrote:
Having trouble creating a dynamic pagertemplate. I want it like this
"Prev 1 2 3 4 Next". The numerically portion being the dynamic part
based on the record count.
I can generate it, but can't get any events to fire.
Is it possible to do? I've tried creating them int he RowCreated
event, DataBound and my own PagerTemplate, but nothing seems to work.
Here is one snippet that I've tried. It causes a postback, but it
isn't handled by the gridview.
protected void gvSearchResults _RowCreated(obj ect sender,
GridViewRowEven tArgs e)
{
if( e.Row.RowType == DataControlRowT ype.Pager)
{
// Get the pager row.
GridViewRow pagerRow = e.Row;
// Get the pager row.
Panel pagesPanel =
(Panel)pagerRow .FindControl("P agesPanel");
//Panel pagesPanel = pagesPanel;
LinkButton myButton = new LinkButton();
myButton.Text = "Prev";
myButton.Comman dName = "Page";
myButton.Comman dArgument = "Prev";
myButton.ID = "PrevPage";
pagesPanel.Cont rols.Add(myButt on);
for (int i = 1; i < ((GridView)send er).PageCount + 1; i++)
{
myButton = new LinkButton();
myButton.Text = String.Format(" {0}&nbsp;", i);
myButton.Comman dName = "Page";
myButton.Comman dArgument = i.ToString();
myButton.ID = "Page" + i;
pagesPanel.Cont rols.Add(myButt on);
}
myButton = new LinkButton();
myButton.Text = "Next";
myButton.Comman dName = "Page";
myButton.Comman dArgument = "Next";
myButton.ID = "NextPage";
pagesPanel.Cont rols.Add(myButt on);
}
}
Jan 24 '07 #3
On Jan 24, 4:24 am, "marty" <m...@jump-technologies.co mwrote:
I have. He's using a dropdown list. Not the same thing as adding
control dynamically.
Did you get this working? I ran into the exact same problem,
dynamically adding a LinkButton to the Pager row. I worked around it
with this snippet in the Page_Load method:

if ( IsPostBack )
{
// Workaround for an ASP.NET bug.
// We dynamically add an "All" LinkButton to the Pager row of the
GridView.
// When this button is clicked then the GridView is to redisplay
with all
// rows shown. The bug is that this LinkButton doesn't get wired up
correctly
// so that while a postback does, in fact, occur - no event handlers
are ever
// called. By checking the __EVENTTARGET form value here we can
look for our
// LinkButton ID (uxShowAll). If we see it then treat it as if the
event were raised.
String eventTarget = Request.Form["__EVENTTAR GET"];
if ( eventTarget.Ind exOf("uxShowAll ") 0 )
ShowAllRows();
return;
}

Feb 8 '07 #4
On Feb 7, 10:37 pm, "Andy" <ayo...@saratog asystems.comwro te:
On Jan 24, 4:24 am, "marty" <m...@jump-technologies.co mwrote:
I have. He's using a dropdown list. Not the same thing as adding
control dynamically.

Did you get this working? I ran into the exact same problem,
dynamically adding a LinkButton to the Pager row. I worked around it
with this snippet in the Page_Load method:

if ( IsPostBack )
{
// Workaround for an ASP.NET bug.
// We dynamically add an "All" LinkButton to the Pager row of the
GridView.
// When this button is clicked then the GridView is to redisplay
with all
// rows shown. The bug is that this LinkButton doesn't get wired up
correctly
// so that while a postback does, in fact, occur - no event handlers
are ever
// called. By checking the __EVENTTARGET form value here we can
look for our
// LinkButton ID (uxShowAll). If we see it then treat it as if the
event were raised.
String eventTarget = Request.Form["__EVENTTAR GET"];
if ( eventTarget.Ind exOf("uxShowAll ") 0 )
ShowAllRows();
return;
}
I solved the numeric pager with prev/next a different way. I let the
pagersettings generate a numeric mode. I then added the link buttons
in on the rowcreate method. I just inserted into the pagertable. Here
is the rowcreate method (grid is called ArchiveGridView ):

if (e.Row.RowType == DataControlRowT ype.Pager)
{
if (ArchiveGridVie w.PageIndex != 0)
{
LinkButton myButton = new LinkButton();
myButton.Text = ArchiveGridView .PagerSettings. PreviousPageTex t;
myButton.Comman dName = "Page";
myButton.Comman dArgument = "Prev";
myButton.ID = "PrevPage";

TableCell cell = new TableCell();
cell.Controls.A dd(myButton);

e.Row.Cells[0].Controls[0].Controls[0].Controls.AddAt (0, cell);
}

if (ArchiveGridVie w.PageIndex != ArchiveGridView .PageCount - 1)
{
LinkButton myButton = new LinkButton();
myButton.Text = ArchiveGridView .PagerSettings. NextPageText;
myButton.Comman dName = "Page";
myButton.Comman dArgument = "Next";
myButton.ID = "NextPage";

TableCell cell = new TableCell();
cell.Controls.A dd(myButton);

// remove the line wrap
e.Row.Cells[0].Controls[0].Controls[0].Controls.AddAt (e.Row.Cells[0].Controls[0].Controls[0].Controls.Count ,
cell);
}
}

Curtis

Feb 28 '07 #5

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>>
0
2074
by: Pascal Costanza | last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monday, February 13, 2006, VUB Campus Etterbeek The VUB (Programming Technology Lab, System and Software Engineering Lab), ULB (deComp) and the Belgian Association for Dynamic Languages (BADL) are very pleased to invite you to a whole day of presentations about the programming languages Self, Smalltalk and Common Lisp by experts in...
0
1657
by: Stuart Shay | last post by:
Hello All I am working on creating a generic theme for my GridView Controls. In My Skin File I have something like this. <asp:GridView SkinId="CustomPager" CssClass="gridView" runat="server"> <PagerTemplate> <font class="smalltext">Page:</font> <asp:Label ID="lblCurrentPage" runat="server"
3
15722
by: Dabbler | last post by:
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.
0
1016
by: Nathan Sokalski | last post by:
I am using a FormView control, and want to access the controls I have created in the PagerTemplate. Right now, I am doing this using the following method: CType(Me.FormViewID.FindControl("PagerTemplateControlID"), LinkButton) However, this gives me the following error:
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)
0
1266
by: khaledrabieh | last post by:
hii all I have made a control for custom paging in gridview and it depends mainly on viewstates ,,,when i embed it inside the pagertemplate of grid view all the viewstates becomes null while when i tried to put my control inside a seperate (tr) it works fine..Any ideas why the viewstates of my control becomes null although i enabled viewstate in page and control?????
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
5
2587
by: bearophileHUGS | last post by:
I often use Python to write small programs, in the range of 50-500 lines of code. For example to process some bioinformatics data, perform some data munging, to apply a randomized optimization algorithm to solve a certain messy problem, and many different things. For that I often use several general modules that I have written, like implementation of certain data structures, and small general "utility" functions/classes, plus of course...
0
9672
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
10439
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
10215
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
7541
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
6783
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
5437
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
4113
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
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.