将DataPager与ListView asp.net一起使用

时间:2014-06-16 07:17:16

标签: c#

我已将ListViewDataPager连接到它,我无法使其正常工作,每次运行该页面时,我都会收到同样的错误:

When the DataBoundControl has paging enabled, either the SelectMethod should return an IQueryable<ItemType> or should have all these mandatory parameters : int startRowIndex, int maximumRows, out int totalRowCount 

<asp:ListView ID="ListView1" ItemType="BudgetApp.Models.Expense" SelectMethod="GetExpenses" DataKeyNames="ExpenseID"
        UpdateMethod="UpdateExpense" DeleteMethod="DeleteExpense" InsertMethod="InsertExpense"
        InsertItemPosition="LastItem" EnableViewState="false" runat="server">
        <LayoutTemplate>
            <div class="outerContainer">
                <table id="productsTable">
                    <tr>
                        <th>Date</th>
                        <th>Payee</th>
                        <th>Desription</th>
                        <th>Category</th>
                        <th>Amount</th>
                    </tr>
                    <tr runat="server" id="itemPlaceHolder"></tr>
                </table>
            </div>
           </LayoutTemplate>
        <ItemTemplate>
            <tr>
                <td><%#Item.Date.ToShortDateString() %></td>
                <td style="text-align: center"><%#Item.Payee %></td>
                <td class="description"><span><%#Item.Description %></span></td>
                <td style="text-align: center"><%#GetCatById(Item.Category) %></td>
                <td><%#Item.Amount.ToString("c") %></td>
                <td>
                    <asp:Button ID="Button1" CommandName="Edit" Text="Edit" runat="server" />
                    <asp:Button ID="Button2" CommandName="Delete" Text="Delete" runat="server" />
                </td>
            </tr>
        </ItemTemplate>
    </asp:ListView>

<asp:DataPager ID="lvDataPager1" runat="server" PagedControlID="ListView1" PageSize="15">
        <Fields>
            <asp:NextPreviousPagerField ShowNextPageButton="False" ButtonCssClass="previousNextLink" />
            <asp:NumericPagerField ButtonCount="10" ButtonType="Link" NumericButtonCssClass="numericLink" />
            <asp:NextPreviousPagerField ShowPreviousPageButton="False" ButtonCssClass="previousNextLink" />
        </Fields>
    </asp:DataPager>

有人可以帮助我吗?

0 个答案:

没有答案