ObjectDataSource does not find SelectCountMethod
c#, objectdatasource
Solution
Your method does not take the same parameters because parameter names are case-sensitive:
public static int GetContentGridItemsCount(Guid? contentItemId,
string contentTypeId, string contentTypeGroup,
Guid? parentItemID, string parentFieldID)
{
}
Is not the same as:
public static int GetContentGridItemsCount(Guid? contentItemID,
string contentTypeID, string contentTypeGroup,
Guid? parentItemID, string parentFieldID)
{
}
The names of the first two arguments have to end with a uppercase `D` in order to match the method signature `ObjectDataSource` is looking for.
Problem
I am trying to use the ObjectDataSource with enabled paging. This requires me to use the SelectCountMethod (so the grid can know how many pages there are). My ObjectDataSource looks like this: ``` <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> ``` And the corresponding static class looks like this: ``` 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) } ``` All is working fine when I don't use paging but when I enable paging I get the following exception which clearly states what it needs: ObjectDataSource 'ItemsDataSource' could not find a non-generic method 'GetContentGridItemsCount' that has parameters: contentItemID, contentTypeID, contentTypeGroup, parentItemID, parentFieldID. My method has these parameter and is non generic so I don't have a clue. Can anyone help me?