gpt4 book ai didi

c# - Gridview 的 Jquery 和更新面板不起作用

转载 作者:行者123 更新时间:2023-12-03 12:19:05 24 4
gpt4 key购买 nike

我必须根据某些给定条件实现 gridview 的闪烁:

gridview row blinking based on some conditions

我能够成功实现它,但随后我被要求在 5 秒内自动引用 gridview,为此我使用了 ajax 更新面板和计时器,但随后我收到了如下新的 javascript 错误: enter image description here

代码:

  <form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div style="border:thin;border-color:cornsilk">
<div> <asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="5000"></asp:Timer></div>
<center>
<asp:UpdatePanel runat="server" ID="UpdateAlarmGrid" UpdateMode="Conditional" OnPreRender="UpdateAlarmGrid_PreRender">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>

<asp:GridView ID="GridAlarm" CssClass="bgRow" EmptyDataText="NoData" CellPadding="7" CellSpacing="1" runat="server" DataKeyNames="id" AutoGenerateColumns="false" ShowHeader="true" OnRowDataBound="GridAlarm_RowDataBound" OnPageIndexChanging="GridAlarm_PageIndexChanging">
<Columns>
<asp:BoundField DataField="TagName" HeaderText="TagName" />
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:BoundField DataField="Value" HeaderText="Value" />
<asp:BoundField DataField="AlarmStatus" HeaderText="Alarm Status"/>
<asp:BoundField DataField="AlarmRaisedDateTime" HeaderText="Alarm Raised" />
<asp:BoundField DataField="AlarmClearedDateTime" HeaderText="Alarm Cleared" />
<asp:BoundField DataField="AlarmAckDateTime" HeaderText="Alarm Acknowledgement" />
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="chk_Select" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</center>

</div>
<div></div>
<div>
<center>
<table>
<tr>
<td>
<asp:Button runat="server" Text="Clear Alarm" ID="BClear" OnClick="BClear_Click" />
</td>
<td></td>
<td>
<asp:Button runat="server" Text="Acknowledge Alarm" ID="BAck" OnClick="BAck_Click" />
</td>
</tr>
</table>
</center>
</div>
</form>

jquery实现代码在 gridview row blinking based on some conditions

定时器代码:

 protected void Timer1_Tick(object sender, EventArgs e)
{
// LRefresh.Text = "refreshing..";
// LRefresh.Visible = true;
bindAlarms();//bind gridview
}

为什么会出现这个问题呢?我该如何解决这个问题?我们该如何预防此类问题?

最佳答案

我猜想 RegisterStartupScript 中的 setBg() 函数后漏掉了分号。添加分号即可实现如下所示的效果

ClientScript.RegisterStartupScript(GetType(), "BG", "setBG('" + GridAlarm.ClientID + "');", true);

关于c# - Gridview 的 Jquery 和更新面板不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24524309/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com