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

Discussion in 'ASP .Net' started by Max2006, Jul 25, 2007.

  1. Max2006

    Max2006 Guest

    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
     
    Max2006, Jul 25, 2007
    #1
    1. Advertising

  2. Max2006

    David Wier Guest

    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.

    --
    David Wier
    MVP/ASPInsider
    http://aspnet101.com
    http://iWritePro.com



    "Max2006" <> wrote in message
    news:e$...
    > 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, Jul 25, 2007
    #2
    1. Advertising

  3. 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 (, 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], Jul 26, 2007
    #3
  4. 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 (, 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], Jul 31, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TmVpbA==?=
    Replies:
    1
    Views:
    689
    Mark Newby
    Apr 27, 2005
  2. Kathy Burke
    Replies:
    0
    Views:
    409
    Kathy Burke
    Jul 27, 2003
  3. Kathy Burke
    Replies:
    0
    Views:
    426
    Kathy Burke
    Jul 27, 2003
  4. José Joye

    Is there anyway to detect a F5-Refresh

    José Joye, Jun 27, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    3,134
    José Joye
    Jun 27, 2006
  5. Vajira

    Is there anyway to iterate STL queue ?

    Vajira, Jan 28, 2005, in forum: C Programming
    Replies:
    3
    Views:
    7,366
    Vajira
    Jan 28, 2005
Loading...

Share This Page