objectdatasource custom paging SelectCount method

D

Dav

I'm trying to implement custom paging in a VS 2005 readonly GridView binding
to an ObjectDataSource control. I added the extra maximumRows and
startRowIndex parameters to my Select method. The Select method had 3
parameters before I added the paging parameters. I added another method
called "GetCounter" to the same class containing the Select method to also
implement the SelectCount attribute. I keep getting an exception because it
is looking for the two original parameters to the Select method even though
the SelectCount method is not supposed to have any parameters at all. This
is the message:

"ObjectDataSource 'ObjectDataSource1' could not find a non-generic method
'GetCounter' that has parameters: selectedStates, sort"

Please help - thanks!
 
Y

Yuan Ren[MSFT]

Hi,

Welcome to MSDN newsgroup!

From your description, I have performed the test but can not reproduce your
issue. So I suggest you post some snippets of the code which include the
method definition in the c sharp file and the select parameter definition
in the HTML source.

This will help me to repro your current problem. Thanks for your
understanding! I¡¯m looking forward your reply!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
 
D

Dav

Thanks for your speedy response! Here's some code from the aspx file and
code-behind (just the relevant snippets):

ASPX page:



<asp:ObjectDataSource runat=server ID="ObjectDataSource1"
TypeName="BusinessClass" SelectMethod="GetProducts"
SelectCountMethod="GetCounter" SortParameterName="sort"
DataObjectTypeName="Product" EnablePaging="true" >
<SelectParameters>
<asp:ControlParameter ControlID="ddlStates"
Name="selectedStates" PropertyName="SelectedValue"
Type="String" />
<asp:parameter Name="sort" Type="String" />

</SelectParameters>

</asp:ObjectDataSource>

<asp:GridView runat=server ID="grdProducts"
AllowPaging=true PagerSettings-Mode=Numeric AllowSorting=True
DataSourceID="ObjectDataSource1" AutoGenerateColumns="False"
OnRowDataBound ="grdProducts_RowDataBound">

<Columns>
 
Y

Yuan Ren[MSFT]

Hi,

Thanks for your reply!

With the information you supplied, I have performed the test with the
Northwind database in my project. However, I can¡¯t reproduce the current
issue since I have used the SelectCountMethod and also hard code the value.

Therefore, I suggest you provide a simple demo which uses the Northwind
database to me. So that, I can debug the current project and find out why
the Exception is thrown. You can send the demo to me as a zip format. My
alias is (e-mail address removed) (remove .online).

I appreciate your understanding, if you have any concerns please let me
know. It¡¯s my pleasure to be of assistance.

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
 
D

Dav

Hi Yuan,

Sorry for the delay in replying. I had shut down VS 2005 several times and
restarted the machine, but the problem persisted. After I powered off the
machine and restarted, the problem went away and the SelectCount method is
working. However, it is requiring me to use the same parameters in the
SelectCount method that I use for the Select method, which isn't a big
problem, but is not the way it is documented to be coded in my understanding.

Thank you.
 
Y

Yuan Ren[MSFT]

Hi,

Thanks for posting!

From your description, I can not understand the issue clearly. Do you mean
the problem can not repro all the time? If this is true, I think maybe the
problem is caused by the data which you use.

Otherwise, I find an article which shows how to use the ObjectDataSource
control and paging:
http://fredrik.nsquared2.com/viewpost.aspx?PostID=229

I hope it will be helpful.

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top