I have an asp.net page with:
- an UpdatePanel
- an ObjectDataSource
- a GridView
The update panel looks like this:
<asp:UpdatePanel ID="MyUpdatePanel" runat="server">
<ContentTemplate>
<asp:DropDownList ID="MyDropDownList" runat="server"
AutoPostBack="True">
...
</asp:DropDownList>
<asp:TextBox ID="MyTextBox" runat="server" />
<asp:Button ID="MySubmitButton" runat="server" text="Submit" />
</ContentTemplate>
</asp:UpdatePanel>
When a user selects an option in the drop down list, something happens with the text box, it may be enabled or disabled, or it may be filled or emptied (depending on the selected option). This change should not affect the rest of the page (that’s why I put it inside an UpdatePanel).
Now, outside the update panel I have the rest of the page. Like this:
<asp:ObjectDataSource ID="MyObjectDataSource" runat="server"
SelectMethod="MySelect"
TypeName="MyType">
<SelectParameters>
<asp:ControlParameter Name="Parameter1" Type="String" ControlID="MyDropDownList" PropertyName="SelectedValue" />
<asp:ControlParameter Name="Parameter2" Type="String" ControlID="MyTextBox" PropertyName="Text" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:GridView ID="MyGridView" runat="server"
AutoGenerateColumns="False"
DataKeyNames="MY_ID"
DataSourceID="MyObjectDataSource">
<Columns>
....
</Columns>
</asp:GridView>
Again, the ObjectDataSource and the GridView are OUTSIDE the UpdatePanel.
But whenever I select an option in the drop down list, the SelectMethod of MyObjectDataSource is invoked!
What I am doing wrong?
Thanks in advance for your help.
Update:
I tried placing MyObjectDataSource and MyGridView in a SEPARATE update panel, but the page sill has the same behavior 🙁
I found a solution.
Now the SelectedMethod of MyObjectDataSource is invoked only when the user clicks MySubmitButton.
🙂