Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. using timer to refresh gridview

using timer to refresh gridview

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestioncsharpasp-net
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arif Liminto
    wrote on last edited by
    #1

    Hi guys, I am still newbie in asp.net I want to refresh gridview every 30 seconds using timer and I have got the problem with calling non-static function to databind the gridview. here is example of my code Timer AlertTimer = null; protected void Page_Load(object sender, EventArgs e) { //load to gridviewAlarm for the first time Alert a = new Alert(); DataTable dt = new DataTable(); a.LoadAlarmFromDB(ref dt); gridviewAlarm.DataSource = dt; gridviewAlarm.DataBind(); AlertTimer = new Timer(); AlertTimer.Start(); AlertTimer.Elapsed += new ElapsedEventHandler(AlertTimer_Elapsed); AlertTimer.Interval = 30000; } public static void AlertTimer_Elapsed(object source, ElapsedEventArgs e) { Alert a = new Alert(); DataTable dt= new DataTable(); a.LoadAlarm(ref dt); **//in here how to call bindGridView() // i have tried those below //but it doesnt work** //Test_MasterPage M = new Test_MasterPage(); //M.bindGridView(); } public void bindGridView() { gridviewAlarm.DataSource = ""; gridviewAlarm.DataBind(); gridviewAlarm.DataSource = m_AlarmDT; gridviewAlarm.DataBind(); } how do i call non static function in static function? thanks so much for the help Regards, Arif

    K C 2 Replies Last reply
    0
    • A Arif Liminto

      Hi guys, I am still newbie in asp.net I want to refresh gridview every 30 seconds using timer and I have got the problem with calling non-static function to databind the gridview. here is example of my code Timer AlertTimer = null; protected void Page_Load(object sender, EventArgs e) { //load to gridviewAlarm for the first time Alert a = new Alert(); DataTable dt = new DataTable(); a.LoadAlarmFromDB(ref dt); gridviewAlarm.DataSource = dt; gridviewAlarm.DataBind(); AlertTimer = new Timer(); AlertTimer.Start(); AlertTimer.Elapsed += new ElapsedEventHandler(AlertTimer_Elapsed); AlertTimer.Interval = 30000; } public static void AlertTimer_Elapsed(object source, ElapsedEventArgs e) { Alert a = new Alert(); DataTable dt= new DataTable(); a.LoadAlarm(ref dt); **//in here how to call bindGridView() // i have tried those below //but it doesnt work** //Test_MasterPage M = new Test_MasterPage(); //M.bindGridView(); } public void bindGridView() { gridviewAlarm.DataSource = ""; gridviewAlarm.DataBind(); gridviewAlarm.DataSource = m_AlarmDT; gridviewAlarm.DataBind(); } how do i call non static function in static function? thanks so much for the help Regards, Arif

      K Offline
      K Offline
      K0306
      wrote on last edited by
      #2

      I think you can not able to call a non-static method from a static method,may be you can change your static function to normal function or you can change the normal function into a delegate function.

      C 1 Reply Last reply
      0
      • K K0306

        I think you can not able to call a non-static method from a static method,may be you can change your static function to normal function or you can change the normal function into a delegate function.

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        You are kind of right, and yet, utterly wrong.

        Christian Graus Driven to the arms of OSX by Vista. Please read this[^] if you don't like the answer I gave to your question. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.

        1 Reply Last reply
        0
        • A Arif Liminto

          Hi guys, I am still newbie in asp.net I want to refresh gridview every 30 seconds using timer and I have got the problem with calling non-static function to databind the gridview. here is example of my code Timer AlertTimer = null; protected void Page_Load(object sender, EventArgs e) { //load to gridviewAlarm for the first time Alert a = new Alert(); DataTable dt = new DataTable(); a.LoadAlarmFromDB(ref dt); gridviewAlarm.DataSource = dt; gridviewAlarm.DataBind(); AlertTimer = new Timer(); AlertTimer.Start(); AlertTimer.Elapsed += new ElapsedEventHandler(AlertTimer_Elapsed); AlertTimer.Interval = 30000; } public static void AlertTimer_Elapsed(object source, ElapsedEventArgs e) { Alert a = new Alert(); DataTable dt= new DataTable(); a.LoadAlarm(ref dt); **//in here how to call bindGridView() // i have tried those below //but it doesnt work** //Test_MasterPage M = new Test_MasterPage(); //M.bindGridView(); } public void bindGridView() { gridviewAlarm.DataSource = ""; gridviewAlarm.DataBind(); gridviewAlarm.DataSource = m_AlarmDT; gridviewAlarm.DataBind(); } how do i call non static function in static function? thanks so much for the help Regards, Arif

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          arifliminto86 wrote:

          I am still newbie in asp.net

          I see that. You're obviously not writing commercial code, this isn't good enough for a beginners class. So, I suggest you either take a class, or buy a book and work through all of it. If you're writing commercial code, then you're a liar and a thief. Your basic problem is that you don't have the slightest clue how ASP.NET works. Your server is doing NOTHING after your page is delivered. To get a page to auto refresh, you need a timer on the client, not on the server.

          Christian Graus Driven to the arms of OSX by Vista. Please read this[^] if you don't like the answer I gave to your question. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.

          B 1 Reply Last reply
          0
          • C Christian Graus

            arifliminto86 wrote:

            I am still newbie in asp.net

            I see that. You're obviously not writing commercial code, this isn't good enough for a beginners class. So, I suggest you either take a class, or buy a book and work through all of it. If you're writing commercial code, then you're a liar and a thief. Your basic problem is that you don't have the slightest clue how ASP.NET works. Your server is doing NOTHING after your page is delivered. To get a page to auto refresh, you need a timer on the client, not on the server.

            Christian Graus Driven to the arms of OSX by Vista. Please read this[^] if you don't like the answer I gave to your question. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.

            B Offline
            B Offline
            Brian W King
            wrote on last edited by
            #5

            Christian Graus wrote:

            Your basic problem is that you don't have the slightest clue how ASP.NET works. Your server is doing NOTHING after your page is delivered. To get a page to auto refresh, you need a timer on the client, not on the server.

            Perhaps you ought to rephrase that. There is actually a method to refresh a page WITHOUT a timer AND from the client. Add the following meta tag to your page; <meta http-equiv="refresh" content="900;URL={the fully qualified url of the page to be refreshed}" /> '900' represents the amount of time between refreshes.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups