|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ObjectDataSource - query being performed twice per page load?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... 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 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 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.
Problems with webcontrol and MultiView
FileUpload, Wizard, and saving the data access control in a Repeater from javascript Wizard, goto page, need to set values of a control in a Repeater RowDataBound bool to string asp.net menu to show only parent, siblings and children as static menus Custom Web Control and Default Height/Width Set file extensions for FileUpload delete rows in dataset pls HELP: webpart acting as shared but should be user (spellchecked) |
|||||||||||||||||||||||