Click here to Skip to main content
13,052,669 members (63,243 online)
Rate this:
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 5-Apr-13 23:15pm
Neetesh Agarwal 6-Apr-13 5:16am
Use Timer.......................
Rate this: bad
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
private void timer1_Tick(object sender, EventArgs e)
     function(); call function here
Rate this: bad
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.
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:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
                <asp:asyncpostbacktrigger controlid="Timer1" eventname="Tick" />
              // place your gridview here to avoid page refresh for regular interval of 5 minutes

Interval="50000" is equals to 5 minutes..

Code behind..
protected void Timer1_Tick(object sender, EventArgs e)
        //write code to load and bind data
Neetesh Agarwal 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 6 Apr 2013
Copyright © CodeProject, 1999-2017
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