ObjectDataSource - query being performed twice per page load?

D

dave.dolan

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...
 
R

russell.mccloy

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!

thanks
RuSs
 
M

Manu

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
 
D

dave.dolan

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.
 

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,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top