objectdatasource custom paging SelectCount method

Discussion in 'ASP .Net Datagrid Control' started by Dav, Jan 10, 2006.

  1. Dav

    Dav Guest

    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!
    Dav, Jan 10, 2006
    #1
    1. Advertising

  2. 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
    Yuan Ren[MSFT], Jan 10, 2006
    #2
    1. Advertising

  3. Dav

    Dav Guest

    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>
    Dav, Jan 11, 2006
    #3
  4. 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 (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
    Yuan Ren[MSFT], Jan 12, 2006
    #4
  5. Dav

    Dav Guest

    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.

    ""Yuan Ren[MSFT]"" wrote:

    > 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 (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
    >
    >
    Dav, Jan 17, 2006
    #5
  6. 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
    Yuan Ren[MSFT], Jan 18, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Y3NvY2t3ZWxs?=

    Objectdatasource Paging Control

    =?Utf-8?B?Y3NvY2t3ZWxs?=, Oct 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    527
    =?Utf-8?B?Y3NvY2t3ZWxs?=
    Oct 17, 2005
  2. =?Utf-8?B?Y3NvY2t3ZWxs?=

    Objectdatasource paging

    =?Utf-8?B?Y3NvY2t3ZWxs?=, Oct 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    717
    =?Utf-8?B?Y3NvY2t3ZWxs?=
    Oct 20, 2005
  3. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    242
    Steven Cheng[MSFT]
    Mar 23, 2006
  4. Kovan A

    Gridview + Custom Paging WITHOUT ObjectDataSource

    Kovan A, Jul 10, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    877
    Teemu Keiski
    Jul 11, 2006
  5. Kovan A

    gridview + custom paging WITHOUT objectdatasource

    Kovan A, Jul 14, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    226
    Kovan A
    Jul 14, 2006
Loading...

Share This Page