我有一个gridview,它在UpdatePanel中有很多列,其中2列用按钮填充。有一个"更新" gridview外的按钮。当用户单击"更新"时,会出现一个UpdateProgress div,这是预期的。但是,当单击gridview中的按钮时,它也会显示,这不是我想要的。如果gridview本身位于UpdatePanel中,如何从UpdateProgress中排除这些按钮?我尝试过ChildrenAsTriggers = False和UpdateMode =有条件但没有帮助。请参阅下面使用的代码。
<asp:UpdateProgress id="UpdateProgress" runat="server">
<ProgressTemplate>
<div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
<asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="Updating PO, please wait ..." ToolTip="Updating PO, please wait ..." style="padding: 10px;position:fixed;top:45%;left:50%;" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdateButton" EventName="Click"/>
</Triggers>
<ContentTemplate>
<!-- Gridview is here -->
</ContentTemplate>
</asp:UpdatePanel>
gridview中的内容示例:
<asp:TemplateField HeaderText="Button Column One">
<HeaderStyle Width="70px" />
<ItemStyle Wrap="False" HorizontalAlign="Center" Width="70px" />
<ItemTemplate>
<asp:Button ID="btnG" runat="server" OnCommand="btnG_Command" Text="View"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False" HeaderText="Drug Details">
<ItemTemplate>
<asp:Button ID="btnA" runat="server" OnCommand="btnA_Command" Text="View" />
</ItemTemplate>
<HeaderStyle Width="60px" HorizontalAlign="Center" />
<ItemStyle Width="60px" HorizontalAlign="Center" />
</asp:TemplateField>
答案 0 :(得分:1)
将Gridview放在单独的更新面板中,并为UpdateProgress控件指定AssociatedUpdatePanelID字段。
<asp:UpdateProgress id="UpdateProgress" runat="server" AssociatedUpdatePanelID="UpdatePanelForButton">
<ProgressTemplate>
<div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
<asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="Updating PO, please wait ..." ToolTip="Updating PO, please wait ..." style="padding: 10px;position:fixed;top:45%;left:50%;" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanelForButton" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdateButton" EventName="Click"/>
</Triggers>
<ContentTemplate>
<!--Button goes here-->
</ContentTemplate>
</asp:UpdatePanel>