selectcountmethod in objectdatasource isn't called

妖精的绣舞 提交于 2019-12-13 18:08:32

问题


I am facing a situation where the selectcountmethod isn't called.

The getdatamethod is called every time, but the count method is not. I also tried to remove the selectcountmethod and set enablepaging="false" and no data is displayed either, even if the dataset is not empty.

<asp:GridView ID="gvGradeDocent" runat="server" AutoGenerateColumns="False" AllowPaging="True"
        DataSourceID="odsGradeDocent" DataKeyNames="Id" PagerStyle-HorizontalAlign="Right"
        PagerSettings-Position="Top" CssClass="table">            
        <Columns>
            <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" Visible="false" />                
            <asp:BoundField DataField="DecisionNo" HeaderText="DecisionNo" SortExpression="DecisionNo" />
            <asp:BoundField DataField="DecisionDate" HeaderText="DecisionDate" SortExpression="DecisionDate"
                DataFormatString="{0:dd/MM/yyyy}" />                
            <asp:CheckBoxField DataField="Status" HeaderText="Status" SortExpression="Status" />
            <asp:CommandField ShowSelectButton="True" ButtonType="Image" SelectImageUrl="~/Images/edit.png" />
            <asp:CommandField ShowDeleteButton="True" ButtonType="Image" DeleteImageUrl="~/Images/delete.png" />
        </Columns>
    </asp:GridView>
</div>
<asp:ObjectDataSource ID="odsGradeDocent" runat="server" SelectMethod="GetDocentGrades"
    TypeName="mash.BusinessLogic.DocentGrade" EnablePaging="True" DeleteMethod="Delete"
    SelectCountMethod="GetCountDocentGrades"></asp:ObjectDataSource>

回答1:


Try working with the code sample here:

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

Check your query first to ensure that data is coming back. Also set the MaximumRowsParameterName and StartRowIndexParameterName parameters to the corresponding params in your select query.



来源:https://stackoverflow.com/questions/8260570/selectcountmethod-in-objectdatasource-isnt-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!