ListView DataPager无法正常工作

时间:2013-02-19 17:58:49

标签: asp.net listview datapager

我有一个带有DataPager的ListView

<asp:ListView ID="ProfilesList" runat="server" OnItemDataBound="ProfilesList_DataBound" >
               <LayoutTemplate>
                   <asp:DataPager runat="server" ID="ContactsDataPager" PageSize="12">
            <Fields>
              <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="true"
                FirstPageText="|&lt;&lt; " LastPageText=" &gt;&gt;|"
                NextPageText=" &gt; " PreviousPageText=" &lt; " />
            </Fields>
          </asp:DataPager>
              <table cellpadding="0" cellspacing="0" class="GridBody" style="padding:0; width:910px; border-bottom-style:none;">
                    <tr class="GridHeader" style="text-align:center;">
                        <td style="width:8px; padding-left:5px; border-bottom-style:none; ">
                        </td>
                        <td style="width:274px; border-bottom-style:none;">
                            Person Info
                        </td>
                        <td style="width:273px; border-bottom-style:none;">
                            Company Info
                        </td>
                        <td style="width:272px; border-bottom-style:none;">
                            User Attributes
                        </td>
                    </tr>
                </table>
                  <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
              </div>
            </LayoutTemplate>

请记住,这只是ListView的第一位,因为整个事情是巨大的。

无论如何,按钮出现了,但它们根本没有做任何事情......我必须在我的代码背后做些什么吗?

1 个答案:

答案 0 :(得分:1)

从ListView中提取DataPager,设置PagedControlID属性并实现PagePropertiesChanging方法:

//set current page startindex, max rows and rebind to false
ContactsDataPager.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
//rebind List View
BindListView();

看一下这篇文章: http://dotnet.dzone.com/articles/paging-listview-using