UpdatePanel+TimerコントロールによるGridviewのデータの自動更新
3096 ワード
1、まずUpdatePanelコントロールを定義し、UpdatePanelコントロールのContentTemplateにTimerコントロールとGridviewコントロールを含み、TimerコントロールをUpdatePanelコントロールのトリガに設定し、Timerコントロール設定の具体的な時間間隔で更新をトリガーする.
……..
2、 timerTest_Tick Gridview 。
protected void timerTest_Tick(object sender, EventArgs e)
{
BindData(); //
}
private void BindData()
{
SqlDataSource1.SelectCommand = @"SELECT A.taskId AS TaskID,
CASE A.taskType WHEN 1 THEN 'UploadProduct' WHEN 2 THEN 'UploadEngine' WHEN 3 THEN 'UploadPattern' WHEN 4 THEN 'UninstallProduct' WHEN 5 THEN 'UninstallEngine' WHEN 6 THEN 'UninstallPattern' WHEN 7 THEN 'RollbackProduct' WHEN 8 THEN 'RollbackEngine' WHEN 9 THEN 'RollbackPattern' ELSE Convert(varchar, A.taskType) END AS TaskType,
submitTime AS SubmitTime,
CONVERT(varchar(100), submitTime, 101) AS formatSubmitDate,
B.UserName AS Submitter,
C.UserName AS
OPERATOR ,
A.description AS Description,
isLocked AS IsLocked,
finishTime AS FinishTime,
PreoprStatus= CASE preoprStatus
WHEN 0 THEN 'Pending'
WHEN 1 THEN 'Processing'
WHEN 2 THEN 'Succeeded'
WHEN 3 THEN 'Failed'
END,
oprStatus= CASE oprStatus
WHEN 0 THEN 'Pending'
WHEN 1 THEN 'Processing'
WHEN 2 THEN 'Succeeded'
WHEN 3 THEN 'Failed'
END,
process.name AS Process
FROM view_task AS A
LEFT JOIN aspnet_Users AS B ON A.submitterId=B.UserId
LEFT JOIN aspnet_Users AS C ON (A.operatorId=C.UserId
AND A.operatorId IS NOT NULL)
LEFT JOIN process ON A.processId=process.id
WHERE A.isTerminated=0 AND (taskType=2
OR taskType=1
OR taskType=3
OR taskType=7
OR taskType=8
OR taskType=9)
ORDER BY SubmitTime DESC";
GridView1.DataBind();
}
:http://blog.csdn.net/zhang_hui_cs/article/details/8113079
http://www.cnblogs.com/Terrylee/archive/2006/11/14/Introduction_to_the_Timer_Control.html