我有一个更新 grid-view 的更新面板,grid-view 连接到 mySql 数据源,更新面板的触发器是一个计时器,每 1 秒滴答一次。但问题是当计时器打勾时,整个页面都会回传。任何的想法 ?<asp:ScriptManager ID="ScriptManager1" OnLoad="Timer1_Tick" runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" ChildrenAsTriggers="true" runat="server"> <ContentTemplate> <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick" Enabled="False"> </asp:Timer> <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource3"> <Columns> <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" /> <asp:BoundField DataField="Sensor1" HeaderText="Sensor1" SortExpression="Sensor1" /> <asp:BoundField DataField="Sensor2" HeaderText="Sensor2" SortExpression="Sensor2" /> <asp:BoundField DataField="Sensor3" HeaderText="Sensor3" SortExpression="Sensor3" /> <asp:BoundField DataField="Sensor4" HeaderText="Sensor4" SortExpression="Sensor4" /> <asp:BoundField DataField="Time" HeaderText="Time" SortExpression="Time" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:MyDatabaseConnectionString %>" SelectCommand="SELECT * FROM [Customer]" OnSelecting="SqlDataSource3_Selecting"></asp:SqlDataSource> </ContentTemplate> <Triggers> <asp:PostBackTrigger ControlID="Timer1" /> </Triggers> </asp:UpdatePanel>计时器背后的代码是: protected void Timer1_Tick(object sender, EventArgs e) { GridView3.DataBind(); }
1 回答
慕妹3242003
TA贡献1824条经验 获得超6个赞
我像下面的代码一样更改了触发器标签,它起作用了:)
<Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" /> </Triggers>
- 1 回答
- 0 关注
- 166 浏览
添加回答
举报
0/150
提交
取消