【问题标题】:ObjectDataSource paging and extra parametersObjectDataSource 分页和额外参数
【发布时间】:2011-06-19 06:53:01
【问题描述】:

我正在使用 ObjectDataSource 进行排序/页面/过滤,如下所示:

        <asp:ObjectDataSource 
                ID="odsCompaniesIndex" runat="server" EnablePaging="true"  
                   SelectMethod="GetCompaniesSubset" 
                   StartRowIndexParameterName="startRowIndex" 
                   MaximumRowsParameterName="maximumRows"
                   SelectCountMethod="GetCompaniesCount" 
                   SortParameterName="sortExpression" 
                   TypeName="Company">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlStatus" 
                 ConvertEmptyStringToNull="true" 
                 DbType="Boolean" PropertyName="SelectedValue" Name="status" />
        </SelectParameters>
    </asp:ObjectDataSource>

使用 ObjectDataSource 的 gridview:

        <asp:GridView ID="gvCompanyIndex" AutoGenerateColumns="true" runat="server" DataSourceID="odsCompaniesIndex"
        AllowPaging="true" DataKeyNames="company_id" AllowSorting="true">
    </asp:GridView>

我想将多个参数(如上述参数)传递给 SelectParameters。方法调用“GetCompaniesSubset”执行但返回时出现以下错误:

ObjectDataSource 'odsCompaniesIndex' 找不到非泛型方法 'GetCompaniesCount' 有 参数:状态。

我的选择方法是:

    public DataSet GetCompaniesSubset(
        int startRowIndex, int maximumRows, string sortExpression, bool status)
{...}

您如何允许 SelectMethod 使用 StartRowIndexParameterName/MaximumRowsParameterName 和任何额外的参数?

谢谢

【问题讨论】:

  • 您如何使用您的ObjectDataSource?你在用GridView吗?

标签: c# asp.net paging objectdatasource custompaging


【解决方案1】:

问题是GetCompaniesCount没有status参数,不是GetCompaniesSubset

【讨论】:

  • 谢谢 我昨天看到了,还以为我怎么这么笨!我需要阅读更多内容!
猜你喜欢
  • 2011-01-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多