views:

63

answers:

2

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?

A: 

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/

IrishChieftain
A: 

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.

diamandiev