Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ObjectDataSource does not find SelectCountMethod

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?

like image 573
Gluip Avatar asked Oct 26 '25 14:10

Gluip


1 Answers

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.

like image 116
Frédéric Hamidi Avatar answered Oct 29 '25 04:10

Frédéric Hamidi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!