Viewstate Disappearance

Discussion in 'ASP .Net' started by Will Lastname, Sep 20, 2005.

  1. The application I'm working on is writing to 2 different tables. The
    first table is the ProjectName, ID (AutoNumber), and the Date/Time
    added as a timestamp. The next table, writes all the components of that
    project, ItemName, Creator, etc... One of the fields in this table is
    ProjID and ID (Autonumber). ProjID is retrieved from a function for
    grabbing the MaxOfID in the first table that is equal to ProjectName
    and the date/time. I performed an executescalar to retrieve this
    integer and set Viewstate("ID") = objCommand.ExecuteScalar

    The problem is that when I set intID = Viewstate("ID") a value of 0 is
    returned. What could cause this viewstate disappearance?
    Will Lastname, Sep 20, 2005
    #1
    1. Advertising

  2. Will Lastname

    Landley Guest

    You need to add your variable first.

    viewstate.Add("ID", 0)

    Landers


    "Will Lastname" <> wrote in message
    news:...
    > The application I'm working on is writing to 2 different tables. The
    > first table is the ProjectName, ID (AutoNumber), and the Date/Time
    > added as a timestamp. The next table, writes all the components of that
    > project, ItemName, Creator, etc... One of the fields in this table is
    > ProjID and ID (Autonumber). ProjID is retrieved from a function for
    > grabbing the MaxOfID in the first table that is equal to ProjectName
    > and the date/time. I performed an executescalar to retrieve this
    > integer and set Viewstate("ID") = objCommand.ExecuteScalar
    >
    > The problem is that when I set intID = Viewstate("ID") a value of 0 is
    > returned. What could cause this viewstate disappearance?
    >
    Landley, Sep 20, 2005
    #2
    1. Advertising

  3. Thanks for the tip Landers. I am sorry to say that I am still getting 0
    returned.
    Will Lastname, Sep 20, 2005
    #3
  4. Will Lastname

    Joe Dotnet Guest

    when are you adding variable to viewstate?

    "Will Lastname" <> wrote in message
    news:...
    > Thanks for the tip Landers. I am sorry to say that I am still getting 0
    > returned.
    >
    Joe Dotnet, Sep 21, 2005
    #4
  5. Will Lastname

    Joe Dotnet Guest

    and when are you reading it?

    "Joe Dotnet" <> wrote in message
    news:eKQz$...
    >
    > when are you adding variable to viewstate?
    >
    > "Will Lastname" <> wrote in message
    > news:...
    >> Thanks for the tip Landers. I am sorry to say that I am still getting 0
    >> returned.
    >>

    >
    >
    Joe Dotnet, Sep 21, 2005
    #5
  6. Function 1 (byval x ...)

    Fill dataset here (ds, "DataTable")
    Dim intID as integer = ds.Tables("DataTable").Rows(0)("ID")
    Response.Write("intID = " & intID & "<br>") 'to test -> works

    Viewstate.Add("ID", Cint(intID))
    Response.Write("intIDVS = " & Viewstate("ID") & "<br>") 'to test
    viewstate value -> works

    End Function


    Sub btnRelease (...)

    Dim intID as integer = Cint(Viewstate("ID"))
    Response.Write("intIDTest = " & intID) 'to test calling viewstate
    value -> doesn't work

    End Sub
    Will Lastname, Sep 21, 2005
    #6
  7. Will Lastname

    Joe Dotnet Guest

    ok, and where it is in page lifecycle?

    "Will Lastname" <> wrote in message
    news:...
    > Function 1 (byval x ...)
    >
    > Fill dataset here (ds, "DataTable")
    > Dim intID as integer = ds.Tables("DataTable").Rows(0)("ID")
    > Response.Write("intID = " & intID & "<br>") 'to test -> works
    >
    > Viewstate.Add("ID", Cint(intID))
    > Response.Write("intIDVS = " & Viewstate("ID") & "<br>") 'to test
    > viewstate value -> works
    >
    > End Function
    >
    >
    > Sub btnRelease (...)
    >
    > Dim intID as integer = Cint(Viewstate("ID"))
    > Response.Write("intIDTest = " & intID) 'to test calling viewstate
    > value -> doesn't work
    >
    > End Sub
    >
    Joe Dotnet, Sep 22, 2005
    #7
  8. I posted that I fixed this yesterday and it didn't update. Anyway,
    thanks for the help Joe. I was writing to the viewstate after my
    datagrid was bound. This caused a value of 0.
    Will Lastname, Sep 22, 2005
    #8
    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. Kepler
    Replies:
    1
    Views:
    360
    Scott Allen
    Nov 2, 2004
  2. onetitfemme
    Replies:
    0
    Views:
    273
    onetitfemme
    Sep 16, 2006
  3. Replies:
    6
    Views:
    320
    Keith Thompson
    Jun 28, 2006
  4. Samuel Rhodes

    AJAX Modal Popup disappearance

    Samuel Rhodes, Apr 20, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    2,248
    Lloyd Sheen
    Apr 20, 2007
  5. Andrew Edwards
    Replies:
    3
    Views:
    91
    Brian Candler
    May 20, 2009
Loading...

Share This Page