我已经嵌套了GridView。当我展开外部行时,它显示内部GridView。两个网格视图都在UpdatePanel内,并使用ObjectDataSource来填充数据。
当我点击展开时,我通过点击按钮通过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>
答案 0 :(得分:0)
我已经用两种方式解决了这个问题。
1:在页面的ASPX端设置select方法选择SelectMethod =“”并在页面回发时分配。
if (Page.IsPostBack)
{
//Always set the select methods.
SetSelectMethods();
}
else
{
ODSGetOptionSearchDataCS.SelectMethod = string.Empty;
ODSWatchlistCS.SelectMethod = string.Empty;
}
private void SetSelectMethods()
{
ODSGetOptionSearchDataCS.SelectMethod = "GetOptionCondors";
ODSWatchlistCS.SelectMethod = "GetOptionWLCondors";
}