Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
i hv a DatagridView in Windows Based project, in which data need to be populated from datbase after every 5 minute or as soon as new data is populated in Database tables
Posted 6-Apr-13 0:15am
Comments
Neetesh Agarwal at 6-Apr-13 5:16am
   
Use Timer.......................
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

public Form
{
    timer1.Interval = (1000) * (300);             // Timer will tick every 300 seconds
    timer1.Enabled = true;                       // Enable the timer
    timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
     function(); call function here
}
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi.. User Ajax Timer do the same.. You can use UpdatePanel to avoid page refresh.
Ex:
Html part..
<asp:scriptmanager runat="server" id="ScriptManager1" xmlns:asp="#unknown" />
        <asp:timer id="Timer1" runat="server" interval="50000" ontick="Timer1_Tick" xmlns:asp="#unknown">
        </asp:timer>
        <asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
            <triggers>
                <asp:asyncpostbacktrigger controlid="Timer1" eventname="Tick" />
            </triggers>
            <contenttemplate>
                
              // place your gridview here to avoid page refresh for regular interval of 5 minutes
 
            </contenttemplate>
        </asp:updatepanel>
Interval="50000" is equals to 5 minutes..
 
Code behind..
protected void Timer1_Tick(object sender, EventArgs e)
    {
        //write code to load and bind data
    }
  Permalink  
Comments
Neetesh Agarwal at 6-Apr-13 5:55am
   
But How in Window Application?

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

  Print Answers RSS
0 Maciej Los 290
1 OriginalGriff 275
2 Sergey Alexandrovich Kryukov 195
3 BillWoodruff 140
4 ProgramFOX 140
0 OriginalGriff 6,524
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,218
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 6 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100