开发者

Why isn't my SelectCountMethod getting called?

开发者 https://www.devze.com 2023-03-06 06:54 出处:网络
I\'m binding a GridView to a ObjectDataSource. I\'m expecting the m_ObjectDataSourceGrid_Selected method to fire twice, once for the Select and again for the Count, but it only fires once.

I'm binding a GridView to a ObjectDataSource.

I'm expecting the m_ObjectDataSourceGrid_Selected method to fire twice, once for the Select and again for the Count, but it only fires once.

What's going on?

<asp:GridView ID="m_GridViewDocClasses" runat="server" AutoGenerateColumns="False"
            DataSourceID="m_ObjectDataSourceGrid" 
            AllowSorting="true">
            <Columns>
                <asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="DocClass.aspx?DocClassId={0}"
                    Text="Edit" />
                <asp:BoundField DataField="Name" HeaderText="Name" S开发者_开发技巧ortExpression="Name" />
                <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />                    
            </Columns>
        </asp:GridView>
    </div>
    <asp:ObjectDataSource ID="m_ObjectDataSourceGrid" runat="server" SelectMethod="GetDocClasses"
        TypeName="SouthernCompany.Generation.SPORT.Business.DocClassBL" OnObjectCreating="m_ObjectDataSourceGrid_ObjectCreating"
        OnSelected="m_ObjectDataSourceGrid_Selected" SelectCountMethod="GetDocClassesCount"
        SortParameterName="sort">
        <SelectParameters>
            <asp:Parameter DefaultValue="" Name="sort" Type="String" />
            <asp:Parameter DefaultValue="0" Name="startRowIndex" Type="Int32" />
            <asp:Parameter DefaultValue="0" Name="maximumRows" Type="Int32" />
            <asp:Parameter DefaultValue="0" Name="docClassId" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>


You can not because you haven't assigned allowpaging, put these three:

AllowPaging="true" 
AllowSorting="true"
PageSize="25"

AllowPaging is needed to call the SelectCountMethod.

remove allowsorting if not needed.


Does your SelectCountMethod is receiving the same parameters as SelectMethod? There's two ways that makes SelectCountMethod acceptable: without any parameter "()" or with the same parameters as SelectMethod, besides Sorting and Paging parameters.

0

精彩评论

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

关注公众号