Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
Hi i have a grid with 500+ records and the data values in the grid are updated every 5min...I need to "AUTO refresh " the grid for every 5 mins

Code am using:
XML
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="3600" ontick="Timer1_Tick"></asp:Timer>

<asp:GridView ID="GridView2
VB
" runat="server" AutoGenerateColumns="False" DataKeyNames="CustomerID"
DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True">





Code behind:
C#
protected void Timer1_Tick(object sender, EventArgs e)
{
GridView2.DataBind();
}


But it is not working please help me ...
Posted

 
Share this answer
 
you can either use a icallback or you can use a web service call to refresh the grid . use javascript timer to call this( either web service or icallback) at every 5 minutes...
 
Share this answer
 
Use SignalR --- the server notifies the client that it has to refresh the data
 
Share this answer
 
XML
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

      <asp:Timer ID="Timer1" runat="server" Interval="20000" OnTick="Timer1_Tick"></asp:Timer>
 <asp:UpdatePanel runat="server">
          <ContentTemplate>
         <asp:GridView ID="DGVsa" runat="server"></asp:GridView>
          </ContentTemplate>
          <Triggers>
              <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />

          </Triggers>

      </asp:UpdatePanel>


in .Cs

protected void Timer1_Tick(object sender, EventArgs e)
       {
Gridbinding()

       }
public void Gridbinding()
{
        sqlSA = "SELECT * FROM Mas_Display"
        DGVsa.DataSource = con.ReturnQuery(sqlSA);
        DGVsa.DataBind();
}
 
Share this answer
 
You can refresh Grid by calling

C#
GridView1.DataBind();
 
Share this answer
 
Comments
CHill60 30-Nov-15 4:31am    
You have added nothing to the other solutions posted over 3 years ago. In fact your "solution" doesn't even suggest where to put this code.
Answering old questions like this will only attract downvotes and reports.
you can refer this link how to autorefresh gridview[^]
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900