Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Max2006 - 25 Jul 2007 21:03 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.