Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9016335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:58:17+00:00 2026-06-16T03:58:17+00:00

I have a datagrid that displays a table which is bound to a SQL

  • 0

I have a datagrid that displays a table which is bound to a SQL server DB.
I would like to set a Timer for every 60 sec, that checks for any update and then displays the latest updated data.

So far I have created an event_handler for datagrid, that includes the object dispatcher timer

private void dataGrid1_loaded(object sender, RoutedEventArgs e)
{
    DispatcherTimer dispatcherTimer = new DispatcherTimer();
    dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
    dispatcherTimer.Interval = new TimeSpan(0, 0, 60);
    dispatcherTimer.Start();
}

Now I don’t know how to proceed further with the event handler to handle the newly updated data from the database.

dispatcherTimer_Tick

Here is my select statement that is used to fill the datagrid.

private void Page_Loaded(object sender, RoutedEventArgs e)
{
    try
    {
        String selectstatement = "select top 2 ItemID, ItemName,ConsumerName, Street, DOJ from ConsumarTB order by ItemID ";
        da = new SqlDataAdapter(selectstatement, con);
        ds = new DataSet();
        da.Fill(ds);
        dataGrid1.ItemsSource = ds.Tables[0].DefaultView;

     }
     catch (SqlException e)
     {
        Console.WriteLine(e.Message);
     }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:58:18+00:00Added an answer on June 16, 2026 at 3:58 am

    There are a lot of ways to improve what you have above. But here’s what I would try for starters.

    Below will populate your datagrid on page load, set a timer to tick every 60 seconds. When the timer ticks, it will call a method to load data to the grid again.

    //On PageLoad, populate the grid, and set a timer to repeat ever 60 seconds
    private void Page_Loaded(object sender, RoutedEventArgs e)
    {
        try
        {
            RebindData();
            SetTimer();
        }
        catch (SqlException e)
        {
            Console.WriteLine(e.Message);
        }
    }
    
    //Refreshes grid data on timer tick
    protected void dispatcherTimer_Tick(object sender, EventArgs e)
    {
        RebindData();
    }
    
    //Get data and bind to the grid
    private void RebindData()
    {
        String selectstatement = "select top 2 ItemID, ItemName,ConsumerName, Street, DOJ from ConsumarTB order by ItemID ";
        da = new SqlDataAdapter(selectstatement, con);
        ds = new DataSet();
        da.Fill(ds);
        dataGrid1.ItemsSource = ds.Tables[0].DefaultView;
    }
    
    //Set and start the timer
    private void SetTimer()
    {
        DispatcherTimer dispatcherTimer = new DispatcherTimer();
        dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
        dispatcherTimer.Interval = new TimeSpan(0, 0, 60);
        dispatcherTimer.Start();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Silverlight DataGrid that contains a single template column which displays a
i have a datagrid that displays long text on couple columns. I have set
I have created a datagrid which displays a Table of records populating from a
I have a DataGrid component that displays a few columns of data. It has
I have a datagrid that is filled with a dataset from an SQL query.
I have a datagrid that I have filled with data from a sql database.
I have a datagrid with 3 of 5 fields from a SQL table. The
I have found that datagrid columns can be dynamically created and bound in Silverlight.
I have a datagrid which displays details for a product. For a particular product
I currently have a datagrid bound to a table with tens of thousands of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.