0

我有这个带有 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 的第一部分,因为整个内容非常庞大。

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

4

1 回答 1

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

于 2013-02-27T11:43:20.493 回答