数据寻呼机内的中继器

发布于 2024-11-19 07:53:10 字数 1634 浏览 2 评论 0原文

我在数据分页器内有一个中继器来显示一些页码,我使用模板化分页器字段,因为里面还有其他数据,并且由于我希望能够重复使用它,所以我将其抽象化输出到嵌入数据分页器中的用户控件。

这是带有用户控件的寻呼机

<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>

这是用户控件

<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: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>

因此,不在中继器中的链接按钮可以正常工作,并且模板寻呼机字段接收 PagerCommand 事件,但是当单击中继器内的链接按钮时,它们会触发回发并它们自己的命令事件,但 TemplatedPagerField 上的 PagerCommand 事件永远不会被触发。

整个要点是一个可重用的控件,它生成类似于 167 < 的 25-50 的分页值。上一页 2 3 4 下一页 >

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="server" Text="< 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 >" 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 >

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城°AllureLove 2024-11-26 07:53:10

永远无法让它正常工作,而是用占位符替换中继器并动态添加链接按钮,在大多数情况下,这工作得很好。因此,用户控件变成了

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

,并在 OnInit 函数中添加了我的动态链接按钮。

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="< Previous" OnCommand="ChangePageCommand" CommandArgument="-1" />
    <span>
        <asp:PlaceHolder ID="LinksPlaceHolder" runat="server" />
    </span>
    <asp:LinkButton  ID="NextPageButton" runat="server" Text="Next >" OnCommand="ChangePageCommand" CommandArgument="1" />
</p>

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文