我试图在启用分页的情况下使用ObjectDataSource。这要求我使用SelectCountMethod (这样网格就可以知道有多少页)。我的ObjectDataSource看起来是这样的:
<asp:ObjectDataSource ID="ItemsDataSource" runat="server" SelectMethod="GetContentGridItems"
TypeName="ContentItemExtensions" SelectCountMethod="GetContentGridItemsCount" EnablePaging="True">
<SelectParameters>
<asp:QueryStringParameter Name="contentItemID" QueryStringField="cid" DbType="Guid" />
<asp:QueryStringParameter Name="contentTypeID" QueryStringField="tid" Type="String" />
<asp:QueryStringParameter Name="contentTypeGroup" QueryStringField="tgid" Type="String" />
<asp:QueryStringParameter Name="parentItemID" QueryStringField="pcid" DbType="Guid" />
<asp:QueryStringParameter Name="parentFieldID" QueryStringField="pfld" type="String" />
</SelectParameters>
相应的静态类如下所示:
public static class ContentItemExtensions
{
public static DataTable GetContentGridItems(Guid? contentItemId,string contentTypeID, string contentTypeGroup, Guid? parentItemID, string parentFieldID,int maximumRows, int startRowIndex)
public static int GetContentGridItemsCount(Guid? contentItemId,string contentTypeID, string contentTypeGroup, Guid? parentItemID, string parentFieldID)
}当我不使用分页时,一切正常,但是当我启用分页时,我得到了以下异常,它清楚地说明了它需要什么:
ObjectDataSource 'ItemsDataSource‘找不到一个非通用的方法'GetContentGridItemsCount’,它有参数: contentItemID、contentTypeID、contentTypeGroup、parentItemID、parentFieldID。
我的方法有这些参数,而且不是泛型的,所以我没有线索。有谁可以帮我?
发布于 2012-04-06 09:58:03
您的方法不接受相同的参数,因为参数名区分大小写:
public static int GetContentGridItemsCount(Guid? contentItemId,
string contentTypeId, string contentTypeGroup,
Guid? parentItemID, string parentFieldID)
{
}与以下情况不同:
public static int GetContentGridItemsCount(Guid? contentItemID,
string contentTypeID, string contentTypeGroup,
Guid? parentItemID, string parentFieldID)
{
}前两个参数的名称必须以大写D结尾,以便与ObjectDataSource正在寻找的方法签名匹配。
https://stackoverflow.com/questions/10041881
复制相似问题