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 7678381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:38:01+00:00 2026-05-31T17:38:01+00:00

Why the ‘index’ always return value 0 although the ticker running and there is

  • 0

Why the ‘index’ always return value 0 although the ticker running and there is a statement ‘index = index + 1’?

'Dim index as integer = 0
'EDIT
Dim GridRowIndex as integer

Protected Sub TickerAnnouncement_Tick(sender As Object, e As System.EventArgs) Handles  TickerAnnouncement.Tick
    lblAnnouncementFooter.Text = GridView1.Rows(index).Cells(0).Text
    'index = index + 1

    If GridRowIndex> GridView1.Rows.Count Then GridRowIndex = 0
End Sub

I have turned the tick enabled but the index still returning the 0 value.

—ADDITION—

I have a property called ‘IndexValue’:

Public Property IndexValue() As Integer
    Get
        Dim s As Integer = DirectCast(ViewState("GridRowIndex"), Integer)
        Return If(ViewState("GridRowIndex") Is Nothing, 0, CInt(ViewState("GridRowIndex")) + 1)
    End Get
    Set(value As Integer)
        ViewState("GridRowIndex") = value
    End Set
End Property
  • 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-05-31T17:38:03+00:00Added an answer on May 31, 2026 at 5:38 pm

    The Timer.Tick will cause a postback. All objects that belongs to the page(member variables,controls etc.) are disposed at the end of the page’s lifecycle. So when it’s rendered to the client, it doesn’t exist in the Server’s memory anymore. HTTP is stateless. Hence every variable(or dynamically created control) must be reinitialized/recreated on postbacks. This is the reason why your index is always 0.

    So you need to store it elsewhere. I would recommend the ViewState:

    ViewState["GridRowIndex"] = ViewState["GridRowIndex"] == null ? 0 : (int)ViewState["GridRowIndex"]+1;
    

    Edit:

    I’ve just realized that this is a VB.NET question,sorry.

    Declare this property:

    Public Property IndexValue() As Integer
        Get
            If ViewState("GridRowIndex") Is Nothing Then ViewState("GridRowIndex") = 0
            Return DirectCast(ViewState("GridRowIndex"), Int32)
        End Get
        Set(value As Integer)
            ViewState("GridRowIndex") = value
        End Set
    End Property
    

    Then set it in your event-handler:

    Protected Sub TickerAnnouncement_Tick(sender As Object, e As System.EventArgs) Handles  TickerAnnouncement.Tick
        lblAnnouncementFooter.Text = GridView1.Rows(IndexValue).Cells(0).Text
        IndexValue += 1
        If IndexValue >= GridView1.Rows.Count Then IndexValue = 0
    End Sub
    

    You will find a complete list of all options on how to persist variables across postbacks here: http://msdn.microsoft.com/en-us/magazine/cc300437.aspx

    • Application
    • Cookies
    • Form Post / Hidden Form Field
    • QueryString
    • Session
    • New State Containers in ASP.NET
    • Cache
    • Context
    • ViewState
    • Web.config and Machine.config Files
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I'm trying to create an if statement in PHP that prevents a single post
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
I was writing code for dragging mechanism which invokes to wait for small period
I've got a string that has curly quotes in it. I'd like to replace
I downloaded PostgreSQL from the official website and ran the .dmg installer. After that
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words

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.