2
我嵌套了GridView。当我展开外部行时,它显示内部GridView。这两个gridviews都在UpdatePanel中,并使用ObjectDataSource来填充数据。ObjectDataSource在嵌套GridView中调用多次
当我点击expand时,我通过单击通过JQuery的按钮做回发。这里,用于外部网格的ObjectDataSource1多次调用SelectMethod。我检查UpdatePanel UpdateMode是有条件的。
如何防止ObjectDataSource多次获取数据?
ASPX:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectCountMethod="GetDevicesCount" SelectMethod="GetDevices" TypeName="Flows" SortParameterName="sortExpression" EnablePaging="True">
<SelectParameters>
<asp:ControlParameter ControlID="txtSearch" Name="searchTerm" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="hdnFieldFromDate" Name="fromDate" PropertyName="Value" Type="String" />
<asp:ControlParameter ControlID="hdnFieldToDate" Name="toDate" PropertyName="Value" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectCountMethod="GetFlowDetailsCount" SelectMethod="GetFlowDetails" OnSelecting="ObjectDataSource2_Selecting" TypeName="Flows" EnablePaging="True">
<SelectParameters>
<asp:ControlParameter ControlID="HiddenDeviceId" Name="deviceId" PropertyName="Value" Type="String" />
<asp:ControlParameter ControlID="hdnFieldFromDate" Name="fromDate" PropertyName="Value" Type="DateTime" />
<asp:ControlParameter ControlID="hdnFieldToDate" Name="toDate" PropertyName="Value" Type="DateTime" />
</SelectParameters>
</asp:ObjectDataSource>
看到这个https://msdn.microsoft.com/en-us/library/aa479353(d=printer).aspx –