ObjectDataSource - query being performed twice per page load?

Discussion in 'ASP .Net Web Controls' started by dave.dolan, May 4, 2006.

  1. dave.dolan

    dave.dolan Guest

    I have an objectdatasource pointing to a special custom built proxy that hits
    an xml webservice to return a collection of my business objects, and I'm
    binding them to a grid view. I noticed that it takes a lot longer than it
    would if I just do the query with the proxy and print the values of the same
    number of objects. I thought at first I was seeing the result of reflection
    and deserialization, but I put a breakpoint on my read method and it turns
    out that the objectdatasource is requesting my data, which hits the web
    service, TWICE per page load. I'm not calling databind directly on the
    gridview or objectdatasource ever, but the object data source is using some
    databound controls as a source for some of it's parameters.

    Could the source of this problem be that I'm re-binding data to the other
    controls serving as a parameter to the object datasource and it's checking
    again, on something like Page_Unload or other to verify that it's contents
    are correct? Is there any way I can turn that off?

    It's like this, in more detail:

    The ObjectDataSource calls a static method of a proxy class that wraps a
    call to the webservice. (Not generated by WSDL.EXE, but it works the same
    way -- The data comes back just fine, and only once when I run it without the
    object data source, specifying the parameters to the static method by hand of
    course) The object datasource has four parameters, a search method
    (dropdown), the search text (textbox), a search logical operation
    (dropdown), and an operand for the logical operation (textbox) The logical
    operations differ for search methods on text fields than those of numeric
    fields, so I rebind them whenever the search method changes.

    Does rebinding a control that serves as a parameter like that cause another
    query to the ODS? or is something else going on that I may be doing wrong?
    Surely it's not meant to hit the data source twice for each load...
    dave.dolan, May 4, 2006
    1. Advertisements

  2. Guest

    Hey any luck on this yet? I have the same issue right now. If a grid
    view is visible on a page and it's datasourceId= <an ODSsource> then it
    will bind. If I say delete a record from my gridview I would call
    myGridview.DataBind(); as I want it to refresh. This works but then my
    gridview binds again?? Weird!

    , May 19, 2006
    1. Advertisements

  3. Manu

    Manu Guest

    AFAIK, if you change any value of the SelectParameters or
    FilterParameters, the ObjectDataSource will set an internal flag to
    rebind on the PreLoad stage. However, if it's the first time that the
    page was requested this flag is set to true, so it will fetch the data
    only once.

    When and where are you changing the parameters?

    Manuel Abadia
    Manu, May 19, 2006
  4. dave.dolan

    dave.dolan Guest

    I changed them on page load after a post back.

    I had a minor breakthrough on this though: When I stopped calling data bind
    on the drop downs, and built their list of items by hand with a .Clear, and a
    series of Adds, it didn't do the double query. It's the DataBind call (and
    more specifically whatever the GridView hooks up to my parameter boxes
    OnDataBound Delegate) I haven't tried it because this works fine for me now,
    just a list of 8 items, but it might be worth a try putting the databind call
    for the parameter controls in the preinit.. don't quote me on that, just
    sounds logical to me.
    dave.dolan, May 19, 2006
    1. Advertisements

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?S01aX3N0YXRl?=

    Quick one - Is SESSION per browser instance or per IP Address?

    =?Utf-8?B?S01aX3N0YXRl?=, Apr 4, 2006, in forum: ASP .Net
    Apr 10, 2006
  2. Razvan
    tony vee
    Sep 10, 2004
  3. chris brat
    chris brat
    May 10, 2006
  4. =?Utf-8?B?QWxCcnVBbg==?=

    Page posts back after having already performed a postback

    =?Utf-8?B?QWxCcnVBbg==?=, Jul 23, 2007, in forum: ASP .Net
    Jul 23, 2007
  5. Max2006
    Walter Wang [MSFT]
    Sep 21, 2007

Share This Page