This is a migrated thread and some comments may be shown as answers.

Problem with paging.

2 Answers 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 23 Feb 2009, 04:11 PM
Hi,

I am having a small problem using the PagerTemplate. Everything is currently working fine, except for when I go to the last page, I can hit next again and it goes back to the first page, then it won't go further.

The code for the pagertemplate is as follows:

<PagerTemplate> 
    <div style="float: right"
        <asp:ImageButton ID="ibtnFirst" runat="server" CommandName="Page" ImageUrl="~/images/first.gif" CommandArgument="First" CssClass="FirstPage" /> 
        <asp:ImageButton ID="ibtnPrev" runat="server" CommandName="Page" ImageUrl="~/images/prev.gif" CommandArgument="Prev" CssClass="PrevPage" /> 
        <asp:ImageButton ID="ibtnNext" runat="server" CommandName="Page" ImageUrl="~/images/next.gif" CommandArgument="Next" CssClass="NextPage" /> 
        <asp:ImageButton ID="ibtnLast" runat="server" CommandName="Page" ImageUrl="~/images/last.gif" CommandArgument="Last" CssClass="LastPage" /> 
    </div> 
</PagerTemplate> 

Between the Last page, and the "First page after last" the currentpageindex doesn't change.

2 Answers, 1 is accepted

Sort by
0
Charles
Top achievements
Rank 1
answered on 23 Feb 2009, 07:02 PM
Ok I have a hack fix for this, but I would still appreciate a better solution.

in the ItemCommand event I added
If e.CommandName = "Page" AndAlso DirectCast(e.CommandArgument, String) = "Next" Then 
            Dim Element = DirectCast(e.Item.Parent.Parent.Parent, Telerik.Web.UI.GridTableView) 
 
            If Element.CurrentPageIndex > 0 AndAlso Element.CurrentPageIndex + 1 = Element.PageCount Then 
                Element.CurrentPageIndex -1 
            End If 
End If 


Which brings me to another question. The reason I had to use e.item.Parent.... is because I have several DetailTables inside of the grid that also have pagers. However when I try to use <Grid>.MasterTableView.DetailTable(0) the PageCount and CurrentPageCount are 1 and 0 repectively, even though the grid has pages. However  "DirectCast(e.Item.Parent.Parent.Parent, Telerik.Web.UI.GridTableView).PageCount" displays the correct page information.
0
Tsvetoslav
Telerik team
answered on 25 Feb 2009, 01:46 PM
Hi Charles,

I could not reproduce this behavior, however, do keep in mind that when using the custom pager template you have to take care to disable the next button when the grid is on the last page. This you can do in mark-up:

<asp:ImageButton....Enabled='<%# IIF(Ctype(DataBinder.Eval(Container, "Paging.CurrentPageIndex"), Integer) + 1  = Ctype(DataBinder.Eval(Container, "Paging.PageCount"), Integer),  "false" , "true") %>' /> 

Hope this helps.

Kind Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Charles
Top achievements
Rank 1
Answers by
Charles
Top achievements
Rank 1
Tsvetoslav
Telerik team
Share this question
or