Re: SelectCountMethod error - looking for parameters?



Miky,

As far as I can tell you, yes, they both look to the SelectParameters,
and yes, it's odd. If you think about it, the SelectCountMethod does
not make sense at all because the total item count could also be
retrieved by the SelectMethod. Also, keep in mind that you can add
attributes to the methods that will be consumed by the ObjectDataSource
with attributes like:

System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert)

and you know why? There is no DataObjectMethodType.SelectCount.

If you want to see a list of the problems and limitations of the
ObjectDataSource you can take a look here:

http://www.manuelabadia.com/blog/PermaLink,guid,32e83915-a503-403e-97c7-e20dcf2e0b7e.aspx

Hope it helps,
Manuel Abadia
http://www.manuelabadia.com


miky wrote:
Manuel,
Thanks for that reply. It was the most direct information I've found
so far. So the SelectCountMethod AND the SelectMethod both look to the
SelectParameters? That seems odd to me. It actually works out for my
situation right now but it would rather make more sense to have two
sets of parameters, one for the SelectMethod and another for the
SelectCountMethod.

My situation works now because I specified the SelectMethod parameters
(SortParameterName, MaximumRowsParameterName,
StartRowIndexParameterName) in the ObjectDataSource declaration and
left the parameter that the SelectMethod and SelectCountMethod have in
common in the SelectParameters hive. But this is a specialized case...

Let me know if you have any further comments/clarifications. Thanks
again for your help.


miky



Manu wrote:
Miky,

The ObjectDataSource will search for a SelectCount method with the
parameters specified in the SelectParameters collection. I know the
best possible design but...

Anyway, in your case, you are using paging and sorting so the
ObjectDataSource will automatically add the parameters for sorting and
paging later. If you don't specify the parameters in the ASPX you don't
need your SelectCount method to have those parameters. However, in your
case there is another parameter, p_PageNum that I don't know what are
you using for that will not be generated automatically by the
ObjectDataSource if you remove it.

Hope it helps,
Manuel Abadia
http://www.manuelabadia.com

miky wrote:
Hi,
I'm trying to get custom gridview paging working and I'm getting the
following error:

"ObjectDataSource 'ObjectDataSource1' could not find a non-generic
method 'count' that has parameters: p_TableName, p_OrderBy, p_MaxRows,
p_PageNum, p_StartRowIndex."

I have a gridview associated to an ObjectDataSource and the
ObjectDataSource is declared in the aspx file as follows:

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
TypeName="LookupData"
SelectCountMethod="count" SelectMethod="selectMFPSData"
MaximumRowsParameterName="p_MaxRows"
SortParameterName="p_OrderBy" EnablePaging="True"
StartRowIndexParameterName="p_StartRowIndex">
<SelectParameters>
<asp:ControlParameter ControlID="lstMFPSTABLES"
Name="p_TableName" PropertyName="SelectedValue"
Type="String" />
<asp:Parameter Name="p_OrderBy" Type="String" />
<asp:Parameter Name="p_MaxRows" Type="Int32" />
<asp:Parameter Name="p_PageNum" Type="Int32" />
<asp:Parameter Name="p_StartRowIndex" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>

The thing I don't understand is the "count" method the error refers to
is the method I've declared in the ObjectDataSource for the
SelectCountMethod property. The parameter list listed in the
declaration (in the <SelectParameters> hive) was generated when I
configured the ObjectDataSource to get a select parameter from a
control (a dropdownlist called lstMFPSTABLES).

So, a couple of questions:
1. Why is it erroring out on the count method, when the parameters are
meant for the select method?
2. Is it possible to parameterize the count method? This ability
would help in certain cases.


Thanks in advance for your help,

miky

.



Relevant Pages

  • ObjectDataSource Bind( ) on Template Column losing data on Sort
    ... allow users to select "Members" of a group, ... <SelectParameters> ... The ObjectDataSource calls my class ok, ... ...It sorts, and returns ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to programmatically access ObjectDataSource values
    ... You can access the ObjectDataSource's SelectParameters from anywhere on the page and change the DefaultValue to anything you'd like. ... you can handle the ObjectDataSource's Selecting event and then modify the parameters for that one select by adding or chaninging the ObjectDataSourceSelectingEventArgs's InputParameters. ... ObjectDataSource in our project. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SelectCountMethod error - looking for parameters?
    ... The ObjectDataSource will search for a SelectCount method with the ... parameters specified in the SelectParameters collection. ... Anyway, in your case, you are using paging and sorting so the ... declaration was generated when I ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SelectCountMethod error - looking for parameters?
    ... common in the SelectParameters hive. ... The ObjectDataSource will search for a SelectCount method with the ... Anyway, in your case, you are using paging and sorting so the ... declaration was generated when I ...
    (microsoft.public.dotnet.framework.aspnet)
  • SelectCountMethod error - looking for parameters?
    ... I'm trying to get custom gridview paging working and I'm getting the ... "ObjectDataSource 'ObjectDataSource1' could not find a non-generic ... declaration (in the <SelectParameters> hive) was generated when I ...
    (microsoft.public.dotnet.framework.aspnet)

Loading