Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Microsoft Visual Studio 2005

I have a datagridview with the following code:
VB
sqlSA = "SELECT * FROM Mas_Display"
DGVsa.DataSource = con.ReturnQuery(sqlSA)


it is my load_form
how do i refresh it every 20 seconds?

i created a timer but im not sure how to use it for refreshing a dgv every 20 seconds.
this is my only code for my timer:
VB
LBLdate.Text = DateTime.Now.ToLongDateString() & " | " & DateTime.Now.ToLongTimeString()


Super Help! Thanks in advance
Posted
Comments
Maciej Los 3-Jun-14 1:52am    
refresh dgv every 20 seconds - Why?
WinForms or WebControls?

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
C#
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
 
v3
Use a control that is called Timer. You place the code to refresh your datagrid in method Tick. (timer.tick)

VB
timer.interval=20000 'Time in miliseconds

timer.enable=true
timer.start()


I hope this is what you are looking for.
 
Share this answer
 
v2

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