Last post Apr 16, 2015 06:36 AM by Zhi Lv - MSFT
Apr 15, 2015 06:35 AM|J3456|LINK
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
Apr 16, 2015 06:36 AM|Zhi Lv - MSFT|LINK
As for this issue please refer to the following articles:
The data source control executes the commands when its corresponding
Insert method is called. The
Select method is called automatically when you call the
DataBind method of the page or of a control bound to the data source control. You can also call any of the four methods explicitly when you want the data source control to
execute a command. Some controls, such as the GridView control, can call the methods automatically, without requiring that you call the methods or that you explicitly call the
DataBind method. For more information, see
Selecting Data Using the SqlDataSource Control and
Modifying Data using the SqlDataSource Control.
For more details, please see: