Adding an Array to viewstate

Discussion in 'ASP .Net' started by bob, May 3, 2004.

  1. bob

    bob Guest

    I am a newbie. How do I add an array to a viewstate, then retreive the
    individual elements?

    Right now, I made an array with random numbers and when I go to access an
    element from different buttons, if I access
    the same element, it looks like it is putting new random numbers in the
    array. I just want to establish an array only once with random numbers, and
    being able to get the same answers when ever I access the elements of the
    array.

    Should I put the array in the init or the load page?

    TIA
    bob, May 3, 2004
    #1
    1. Advertising

  2. bob

    Raterus Guest

    should be as simple as this..

    Dim myArray() As String = {"abc", "def", "ghi"}
    viewstate("myarray") = myArray
    Dim anotherArray() As String = CType(viewstate("myarray"), String())


    "bob" <> wrote in message news:kZtlc.511021$...
    > I am a newbie. How do I add an array to a viewstate, then retreive the
    > individual elements?
    >
    > Right now, I made an array with random numbers and when I go to access an
    > element from different buttons, if I access
    > the same element, it looks like it is putting new random numbers in the
    > array. I just want to establish an array only once with random numbers, and
    > being able to get the same answers when ever I access the elements of the
    > array.
    >
    > Should I put the array in the init or the load page?
    >
    > TIA
    >
    >
    >
    Raterus, May 3, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Rush
    Replies:
    2
    Views:
    499
    Ben Rush
    Dec 5, 2003
  2. Steph
    Replies:
    2
    Views:
    1,642
    heislord5
    May 11, 2011
  3. ujjc001
    Replies:
    0
    Views:
    1,359
    ujjc001
    Jul 27, 2005
  4. sck10
    Replies:
    6
    Views:
    895
    sck10
    Sep 1, 2006
  5. mark

    Viewstate errors... how do I get viewstate working?

    mark, Feb 20, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    265
Loading...

Share This Page