Gridview 内的 Listview 分页不起作用

发布于 2024-09-24 19:12:03 字数 1675 浏览 0 评论 0原文

我有一个嵌套在网格视图内的列表视图。

我正在尝试在列表视图上进行分页。我以为它会显示分页控件,然后正常地翻阅它们。

它确实显示控件,并将显示的结果集限制为适当的记录数(pageSize),但是当我单击分页控件时,网格会刷新,并且嵌套列表视图没有任何变化(它仍然在第一页上)。

我尝试将列表视图嵌套在更新面板内,但行为仍然存在。 gridview 本身已经在 updatepanel 中。

这就是我的布局:

<Gridview ID="gvApplications" DataSourceID="odsApplications" DataKeyNames="ID" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Functions">
                 <ItemTemplate>
                     <asp:ListView ID="lvFunctions" runat="server" DataSource='<%#Eval("ApplicationFunctions") %>'
                      DataKeyNames="ID">
                     <LayoutTemplate>
                         <asp:DataPager ID="dpFunctions" runat="server" PageSize="1" PagedControlID="lvFunctions">
                            <Fields>
                                <asp:NextPreviousPagerField />
                            </Fields>
                         </asp:DataPager>
                         <ul>
                         <li>
                            <span ID="itemPlaceholder" runat="server" />
                         </li>
                         </ul>
                     </LayoutTemplate>
                     <ItemTemplate>
                        <asp:Label ID="lblFunction" runat="server" Text='<%# Eval("ApplicationFunction.Name") %>' />
                     </ItemTemplate>
                     </asp:ListView>
                 </ItemTemplate>
            </asp:TemplateField>
</Columns>
</Gridview>

有想法吗?

I have a listview nested inside a gridview.

I'm trying to get paging working on the listview. I thought that it would display the paging controls, and just page through them normally.

It does display the controls, and limits the result set shown to the appropriate number of records (pageSize) but when I click on the paging controls the grid refreshes and nothing changes with the nested listview (it's still on the first page).

I've tried nesting the listview inside an updatepanel, but the behavior remains. The gridview itself is already in an updatepanel.

So this is the layout I've got:

<Gridview ID="gvApplications" DataSourceID="odsApplications" DataKeyNames="ID" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Functions">
                 <ItemTemplate>
                     <asp:ListView ID="lvFunctions" runat="server" DataSource='<%#Eval("ApplicationFunctions") %>'
                      DataKeyNames="ID">
                     <LayoutTemplate>
                         <asp:DataPager ID="dpFunctions" runat="server" PageSize="1" PagedControlID="lvFunctions">
                            <Fields>
                                <asp:NextPreviousPagerField />
                            </Fields>
                         </asp:DataPager>
                         <ul>
                         <li>
                            <span ID="itemPlaceholder" runat="server" />
                         </li>
                         </ul>
                     </LayoutTemplate>
                     <ItemTemplate>
                        <asp:Label ID="lblFunction" runat="server" Text='<%# Eval("ApplicationFunction.Name") %>' />
                     </ItemTemplate>
                     </asp:ListView>
                 </ItemTemplate>
            </asp:TemplateField>
</Columns>
</Gridview>

Ideas?

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

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

发布评论

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

评论(2

凉城已无爱 2024-10-01 19:12:03

老实说,我会考虑在这里使用主从模式。这方面有很多代码示例。例如:

Google:带有子对象的主详细信息示例

在某些情况下,详细信息视图(在您的情况下为子对象)将显示在单独的页面上。无论哪种方式,通过在单独的详细信息视图中显示子对象,您都可以避免嵌套带来的编码和显示问题。

Matt Berseth 在这个主题上有一些最好的代码示例:

http://mattberseth.com/blog/gridview /

Honestly, I would consider using a master-details pattern here. There are a lot of code examples on this. For example:

Google: Master Details Examples with Child Objects

There are also scenarios where the details view (child objects in your case) would display on a separate page. Either way, by displaying the child objects in a separate details view, you avoid the coding and display issues that come with nesting.

Matt Berseth has some of the best code examples out there on this topic:

http://mattberseth.com/blog/gridview/

九局 2024-10-01 19:12:03

如果列表视图不使用数据源控件,列表视图/数据分页器组合将无法正常工作。

尝试在模板字段中包含数据源控件(objectdatasource 可能适用)。

Listview / datapager combination do not work properly if the listview does not use a datasource control.

Try including a datasource control (objectdatasource could be applicable) in the template field.

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