gpt4 book ai didi

asp.net - 为什么我的 SelectCountMethod 没有被调用?

转载 作者:行者123 更新时间:2023-12-02 13:49:18 25 4
gpt4 key购买 nike

我将 GridView 绑定(bind)到 ObjectDataSource

我期望 m_ObjectDataSourceGrid_Selected 方法触发两次,一次针对 Select,另一次针对 Count,但它只触发一次。

发生什么事了?

<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" SortExpression="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>

最佳答案

你不能因为你还没有分配allowpaging,把这三个:

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

调用SelectCountMethod需要AllowPaging。

如果不需要,请删除允许排序。

关于asp.net - 为什么我的 SelectCountMethod 没有被调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5997752/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com