Hi,
I have a search result GridView bound to an ObjectDataSource. Once I open
the asp.net page, the ObjectDataSource automatically refreshes the GridView
which is the default behavior.
I am trying to disable automatic query feature in ObjectDataSource, such
that it query the database only when the user click on Search button.
Is there anyway to prevent ObjectDataSource query the database when the page
opens?
Thank you,
Max
David Wier - 25 Jul 2007 21:39 GMT
Try removing the ObjectDataSource from the scenario altogether -
then, with the button's click event, add:
Gridview1.DataSource=(YourClass.Yourmethod)
Gridview1.Databind
Remember, though, in removing the DatasourceID from the Gridview, DO NOT let
it refresh the schema - it will remove all your fields and formatting,
giving you the default look and feel.

Signature
David Wier
MVP/ASPInsider
http://aspnet101.com
http://iWritePro.com
> Hi,
>
[quoted text clipped - 10 lines]
> Thank you,
> Max
Walter Wang [MSFT] - 26 Jul 2007 04:38 GMT
Hi Max,
My colleague Steven and WenYuan happen to have answered similar questions,
would you please check if the solution there helps? Thanks.
# 2.0 controlling Databinding - microsoft.public.dotnet.framework.aspnet
http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/brow
se_thread/thread/b44e282bb0b0f95f
# GridView databinding - microsoft.public.dotnet.framework.adonet
http://groups.google.com/group/microsoft.public.dotnet.framework.adonet/brow
se_thread/thread/c077e9c12dc1b9e3
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Walter Wang [MSFT] - 31 Jul 2007 04:21 GMT
Hi Max,
I'm writing to check the status of this post. Please feel free to let me
know if there's anything else I can help.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.