views:

122

answers:

3

Hi

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 enter 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>
A: 

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

Costa
+1  A: 

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

CAbbott
A: 

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'.

madatanic