ObjectDataSource does not find SelectCountMethod

I am trying to use an ObjectDataSource with paging enabled. This requires me to use SelectCountMethod (so that 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)
}

      

Everything works fine when I don't use paging, but when I turn on paging, I get the following exception, which clearly states what it needs:

ObjectDataSource 'ItemsDataSource' could not find non-generic GetContentGridItemsCount method that has parameters: contentItemID, contentTypeID, contentTypeGroup, parentItemID, parentFieldID.

My method has this parameter and is not generic, so I have no clue. Can anyone help me?

+3


source to share


1 answer


Your method does not accept the same parameters as the parameter names are case sensitive:

public static int GetContentGridItemsCount(Guid? contentItemId,
    string contentTypeId, string contentTypeGroup,
    Guid? parentItemID, string parentFieldID)
{
}

      

Not the same as:



public static int GetContentGridItemsCount(Guid? contentItemId,
    string contentTypeId, string contentTypeGroup,
    Guid? parentItemID, string parentFieldID)
{
}

      

The first two arguments must end in uppercase D

to match the method that is looking for signatures ObjectDataSource

.

+5


source







All Articles