UpdatePanel和Timer使用问题
aspx文件:
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="TimerForNew" runat="server" Interval="5000"
OnTick="TimerForNew_Tick" Enabled="true">
</asp:Timer>
<div style="text-align:center;"><h2>照片传回实时监测</h2></div>
<div style="text-align:center;">
<asp:DataGrid ID="dlNews" runat="server" AutoGenerateColumns="False"
BorderColor="#0E7C6E" BorderWidth="1px" CellPadding="3" Font-Size="12px" Width="92%" >
<SelectedItemStyle CssClass="DataGrid-selected"/>
<AlternatingItemStyle CssClass="DataGrid-alter" HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle CssClass="DataGrid-item" HorizontalAlign="Center" VerticalAlign="Middle" />
<HeaderStyle CssClass="DataGrid-header" HorizontalAlign="Center" VerticalAlign="Middle" />
<Columns>
<asp:BoundColumn DataField="orderID" HeaderText="序号" >
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="6%"/>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundColumn>
<asp:BoundColumn DataField="cCmpName" HeaderText="公司名">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="14%"/>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundColumn>
<asp:BoundColumn DataField="cCarNum" HeaderText="车牌号">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="10%"/>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundColumn>
<asp:BoundColumn DataField="cTelNum" HeaderText="终端号">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="12%"/>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundColumn>
<asp:BoundColumn DataField="cftrName" HeaderText="站 点">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="12%"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="cOpType" HeaderText="拍照类型">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="8%"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="dOpTime" HeaderText="拍照时间">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="16%"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="cPhotoPath" HeaderText="照片名称" Visible="false">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="18%"/>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
cs文件:
protected void TimerForNew_Tick(object sender, EventArgs e)
{
//if (flag == 1)
//{
// Label1.Text = "1变化";
// flag = 2;
//}
//else
//{
// Label1.Text = "2变化";
// flag = 1;
//}
newNum = Int32.Parse(BLL.Report.GetAllInfo().Rows[0]["cID"].ToString());
DataTable table = new DataTable();
if (newNum > num || isClear)
{
table = BLL.Report.GetNewPho(num + 1, newNum);
//table = BLL.Report.GetNewPho(num, newNum);
table.Columns.Add(new DataColumn("orderID", typeof(string)));
table.Columns.Add(new DataColumn("cCmpName", typeof(string)));
for (int i = 0; i < table.Rows.Count; i++)
{
table.Rows[i]["orderID"] = i + 1;
table.Rows[i]["cCmpName"] = BLL.Company.GetCompanyTable(table.Rows[i]["cTelNum"].ToString().Substring(0, 4)).Rows[0]["cCmpName"].ToString();
}
dlNews.DataSource = table.DefaultView;
dlNews.DataBind();
isClear = false;
}
}
现在程序不能进入到TimerForNew_Tick方法,定时器不知道为什么不可用,请帮帮忙