How to set TotalRowCount property for data pager control in paging of ListView?

3k Views Asked by At

I work in listView with datapager control and create paging for list view as follows:

 <asp:ListView ID="lvList" runat="server">
    <LayoutTemplate>
        <ul>
            <li runat="server"></li>
        </ul>
    </LayoutTemplate>
    <ItemTemplate>
        <li>
            </li>
    </ItemTemplate>
</asp:ListView>
 <asp:DataPager ID="List" runat="server" PageSize="10" PagedControlID="lvList">
    <Fields>
       <asp:NumericPagerField ButtonType="Button" />
    </Fields>
 </asp:DataPager>

and I retrieve list of paged data to listview, in every page number changed data for list view will bound and get 10 rows throught specific function like this:

// this code retrieve list<> contains 10 rows
lvList.DataSource=RetrievePaged(pageNumber,pageSize,sortExpression);
lvList.DataBind();

when run this paging not work because the TotalRowCount=10. How I can change this property and set it to be total number of rows in table?

1

There are 1 best solutions below

0
On

let "list" be your datapager: list.PageSize = 10 the code above does the thing,piece of cake;)