[英]GridView flickering when placed inside UpdatePanel with Timer (asp.net)
我已经将GridView和计时器放置在UpdatePanel中。 现在的问题是,每次计时器刷新时,GridView中的图像都会闪烁。 有人知道为什么吗? 这是我的代码:
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
<ContentTemplate>
</asp:Timer>
<asp:Timer ID="Timer1" runat="server" Interval="100" OnTick="Timer1_Tick">
</asp:Timer>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:masterConnectionString3 %>" SelectCommand="[GET DATA FROM SQL SERVER]"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="Black" GridLines="None" Width="940px">
<Columns>
<asp:BoundField DataField="Column1" HeaderText="Column1" HtmlEncode="False" ReadOnly="True" SortExpression="Column1" />
<asp:BoundField DataField="Column2" HeaderText="Column2" ReadOnly="True" SortExpression="Column2" />
</Columns>
</asp:GridView>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
我通过在GridView中使用本地图像并仅在需要时使用以下方式更新GridView来修复它:
updatepanel和UpdatePanel.Update();
中的UpdateMode="Conditional"
UpdatePanel.Update();
在后面的代码中。 现在很棒!
参考和示例代码可以在以下位置找到: http : //msdn.microsoft.com/zh-cn/library/system.web.ui.updatepanel.updatemode.aspx
GridView闪烁,因为计时器发生了回发。 将计时器放在其他更新面板中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.