How To Auto refresh a Web Page Every Two Minutes

You can use  ASP.Net Timer Control, Set the interval, interval is in miliseconds , for 2 seconds use 2000 as interval. Using below method you can refresh the gridview or any other control after specific time interval. This type of code we need when we need to refresh the page to show the latest data on screen.

Use below code

Use-of-Timer-Control.aspx

 <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>


 <asp:UpdatePanel runat="server" id="TimedPanel" updatemode="Conditional">
    <Triggers>
        <asp:AsyncPostBackTrigger controlid="UpdateTimer" eventname="Tick" />
        <asp:PostBackTrigger ControlID="btnSubmit" />
    </Triggers>
    <ContentTemplate>

     <asp:Timer runat="server" id="UpdateTimer" interval="2000"  OnTick="Timer1_Tick"  />
 
        <asp:GridView ID="gdvUsers" AutoGenerateColumns="false" CellPadding="2" CellSpacing="2"  OnRowDataBound="gdvUsers_RowDataBound" runat="server">
       <HeaderStyle BackColor="#CADEAB" />
       <Columns>
      You can use any control here accoring to requirement.
 

  </Columns>
        </asp:GridView>
    </ContentTemplate></asp:UpdatePanel>  
   

Use-Of-TimerControl.aspx.cs

 protected void Timer1_Tick(object sender, EventArgs e)
    {
        try
        {
         binddata();
        }

        catch { }
    }

Related Alrticles

FREE!!! Registration