SqlDataSource ControlParameter still fires in UpdatePanel RRS feed

  • Question

  • User411536124 posted

    I have a GridView connected to a SqlDataSource, which has a ControlParameter (SelectedValue) connected to a DropDownList. All works fine.

    Now I want to use an UpdatePanel so the GridView only updates after I select from the DropDownList and click a Button.

    I've enclosed the GridView and the DropDownList in separate UpdatePanels, and set the triggers, etc.

    So far it still appears to work OK from the front end, the GridView doesn't update until I click the button.

    But... if I trace the SQL going to the database, I can see that the SQL code that populates the SqlDataSource is still running, even though the GridView isn't being refreshed. (the DropDownList has AutoPostBack set for other reasons internal to its own UpdatePanel, but that shouldn't affect anything outside it).

    I tried putting the SqlDataSource inside or outside the UpdatePanel but it makes no difference.

    Does a ControlParameter on a SqlDataSource ignore/override the UpdatePanel functionality? Ideally I don't want to hit the database if I don't need to.

    I'd rather have a declarative solution in the aspx file than resort to code, if possible.

    Edit: I should say that I have set UpdateMode="Conditional" for both UpdatePanels

    Wednesday, April 15, 2015 6:35 AM