每隔5秒自动换页(适用于数据量小的表)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<table class="infotable">
<tr>
<td>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="gvValueList" runat="server">
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</table>
<asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick">
</asp:Timer>
</form>
</body>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<table class="infotable">
<tr>
<td>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="gvValueList" runat="server">
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</table>
<asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick">
</asp:Timer>
</form>
</body>
</html>
protected void Timer1_Tick(object sender, EventArgs e)
{
if (this.gvValueList.PageCount > 1)
{
if (this.gvValueList.PageIndex == this.gvValueList.PageCount - 1)
{
//Response.Redirect("default2.aspx");
//自动转到第一页
this.gvValueList.PageIndex = 0;
fun.GVDataInit(bllsql.SelOverallPJSituation, gvValueList);//绑定GV
}
else
{
this.gvValueList.PageIndex = this.gvValueList.PageIndex + 1;
fun.GVDataInit(bllsql.SelOverallPJSituation, gvValueList);
}
}
}
if (this.gvValueList.PageCount > 1)
{
if (this.gvValueList.PageIndex == this.gvValueList.PageCount - 1)
{
//Response.Redirect("default2.aspx");
//自动转到第一页
this.gvValueList.PageIndex = 0;
fun.GVDataInit(bllsql.SelOverallPJSituation, gvValueList);//绑定GV
}
else
{
this.gvValueList.PageIndex = this.gvValueList.PageIndex + 1;
fun.GVDataInit(bllsql.SelOverallPJSituation, gvValueList);
}
}
}