Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Customize DataPager Control 1

Status
Not open for further replies.

jgd1234567

Programmer
May 2, 2007
68
GB
Hi, i'm trying to use the DataPager control and i have two problems:

1. It uses the the physical url and not actual url, ie default.aspx instead of default.htm (i use isapi rewrite to rewrite the url)

2. I can't see how i can customize the way the paging works. I can see there is a QueryStringField property but this isn't perfect. I would like to be able to set a property ie PagerUrl="/{0}/" where {0} is replaced with the page number.

I would imagine my solution to the second problem would solve the first but i can not see how to implement this. I tried creating my own server control inheriting from the DataPager control and have added my PagerUrl property but now i'm stuck. Which method should i override? I looked at CreatePagerFields but what next. I have some minor experience creating server controls but i am way out of my depth on this one and was hoping someone could help.

Appreciate the help. Thanks
 
Hi cheers, I've been looking at the template pager field but it appears as though there is a bug with it. I tried:

<asp:DataPager ID="pager" runat="server" PageSize="1" QueryStringField="Page">
<Fields>
<asp:TemplatePagerField>
<PagerTemplate>
<%# Utilities.DataPager(Convert.ToInt32(Container.TotalRowCount > 0 ? Math.Ceiling(((double)(Container.StartRowIndex + Container.MaximumRows) / Container.MaximumRows)) : 0), Container.PageSize, Container.TotalRowCount, "/news/")%>
</PagerTemplate>
</asp:TemplatePagerField>
</Fields>
</asp:DataPager>

My Utilities.DataPager method generates my pager for me but it does not pass the correct StartRowIndex into my method (it passes 0 all the time). I added the NumericPagerField above my TemplatePagerField which now renders two pagers but now my templated one works for some strange reason. I could add a css class to hide this (since visible="false" doesn't work) but this seems like a hack.

Appreciate further help.
 
I would guess that if you are calling your method every time, that it "resets" itself and therefore returns 0 every time. I don't have 2008 here to test any of this out but the example given in the MSDN link above seems like it should work. If your implementation of this doesn't work, then it's more likely an error in your code rather than a bug in the framework.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
This definately looks like a bug. I added the following:

<asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="false" ShowNextPageButton="false" ShowPreviousPageButton="false" />

To the Fields part of the DataPager and it seems to have done the trick.

Cheers again for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top