开发者

Repeater inside Data Pager

I have a Repeater inside a datapager to display some of the page numbers, I'm using a templated pager field because there is other data inside there as well, and since I want to be able to re-use this, I have abstracted it out to a user control which is embedded in the data pager.

Here is the pager with the user control

<asp:DataPager ID="MessagesDataPager" SkinID="AdminCorrespondenceDataPager" PagedControlID="MessagesListView" runat="server">
    <Fields>
        <asp:TemplatePagerField OnPagerCommand="Pager_OnPagerCommand">
            <PagerTemplate>
                <uc:ListViewPager Id="Pager" runat="server" />
            </PagerTemplate>
        </asp:TemplatePagerField>
    </Fields>
</asp:DataPager>

Here is the user control

<p class="pag">
    <span class="pagerSummaryPages"><asp:Literal ID="SummaryLiteral" runat="server" /></span>
    <asp:LinkButton ID="PreviousPageButton" runat=开发者_如何学Go"server" Text="&lt Previous" OnCommand="ChangePageCommand" CommandArgument="-1" />
    <span>
        <asp:Repeater ID="PageLinksRepeater" OnItemDataBound="PageLinksRepeater_OnItemDataBound" runat="server">
            <ItemTemplate>
                <asp:LinkButton ID="PageLink" CssClass="pageLink" runat="server" OnCommand="ChangePageCommand" />
            </ItemTemplate>
        </asp:Repeater>
    </span>
    <asp:LinkButton  ID="NextPageButton" runat="server" Text="Next &gt;" OnCommand="ChangePageCommand" CommandArgument="1" />
</p>

So the link buttons that are not in the repeater work correct and the template pager field receives the PagerCommand event, but when the link buttons inside the repeater are clicked they fire a postback and their own command event, but the PagerCommand event on the TemplatedPagerField is never fired.

The whole point of this is a re-useable control that generates paging values similar to 25-50 of 167 < Previous 2 3 4 Next >


Never could get this to work correctly, instead replaced the repeater with a Placeholder and dynamically added link buttons to it, for the most part this works pretty well. So the user control became

<p class="pag">
    <span class="pagerSummaryPages"><asp:Literal ID="SummaryLiteral" runat="server" /></span>
    <asp:LinkButton ID="PreviousPageButton" runat="server" Text="&lt Previous" OnCommand="ChangePageCommand" CommandArgument="-1" />
    <span>
        <asp:PlaceHolder ID="LinksPlaceHolder" runat="server" />
    </span>
    <asp:LinkButton  ID="NextPageButton" runat="server" Text="Next &gt;" OnCommand="ChangePageCommand" CommandArgument="1" />
</p>

and in the OnInit function added my dynamic link buttons to it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜