Is there anyway to prevent ObjectDataSource query the database when the page opens?

M

Max2006

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
 
D

David Wier

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

Walter Wang [MSFT]

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 ([email protected], 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.
 
W

Walter Wang [MSFT]

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 ([email protected], 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.
 

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,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top