ObjectDataSource 分页和额外参数
我正在使用 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”执行,但在返回时出现以下错误:
对象数据源“odsCompaniesIndex” 找不到非通用方法 'GetCompaniesCount' 有 参数:状态。
我的 SelectMethod 是:
public DataSet GetCompaniesSubset(
int startRowIndex, int maximumRows, string sortExpression, bool status)
{...}
如何允许 SelectMethod 使用 StartRowIndexParameterName/MaximumRowsParameterName 和任何额外参数?
谢谢
I'm using an ObjectDataSource to sort/page/filter as below:
<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>
The gridview consuming the ObjectDataSource:
<asp:GridView ID="gvCompanyIndex" AutoGenerateColumns="true" runat="server" DataSourceID="odsCompaniesIndex"
AllowPaging="true" DataKeyNames="company_id" AllowSorting="true">
</asp:GridView>
I want to pass in a number of parameters like the one above into SelectParameters. The method call 'GetCompaniesSubset' executes but on the return I get the following error:
ObjectDataSource 'odsCompaniesIndex'
could not find a non-generic method
'GetCompaniesCount' that has
parameters: status.
My SelectMethod is:
public DataSet GetCompaniesSubset(
int startRowIndex, int maximumRows, string sortExpression, bool status)
{...}
How do you allow the SelectMethod to utilise StartRowIndexParameterName/MaximumRowsParameterName and any extra parameters?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是
GetCompaniesCount
没有status
参数,而不是GetCompaniesSubset
。The problem is that
GetCompaniesCount
does not havestatus
parameter, notGetCompaniesSubset
.