开发者

How Grid paging works?

The paging is working fine here, the problem is I don't know how it works, because when I put a break point and a logger in the GetCustomers method, I found that parameters maximumRows and startRowIndex are always 0, 0.

I have no clue why StartRowIndexParameterName, and MaximumRowsParameterName are created and how they are used. If they are used in custom mode, so how to e开发者_运维百科nter that mode?

Thanks

<body>
    <form id="form1" runat="server">
    <div>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectCountMethod="Count"
            SelectMethod="GetCustomers" TypeName="Pilots.BLL.Customer">
            <SelectParameters>
                <asp:Parameter Name="maximumRows" Type="Int32" />
                <asp:Parameter Name="startRowIndex" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>


        <asp:GridView ID="GridView1" runat="server" AllowPaging="true" PageIndex="0" PageSize="10"
            DataSourceID="ObjectDataSource1">
        </asp:GridView>
    </div>
    </form>
</body>


Here's a pretty thorough MSDN Article on GridView and Paging. Should be able to answer most all of your questions.


Those 2 parameters are used for custom paging on the gridview. That will be passed to SQL server to determine at what index to start the page (startRowIndex) and how many items on one gridview page (maximumRows).

The 'startRowIndex' will change depending on what the GridView.PageIndex is. The number of rows returned from the method depends on what value set on 'maximumRows'.


It seems that I had to use EnablePaging as descried here,

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.enablepaging.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜