Viewstate Disappearance

W

Will Lastname

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?
 
W

Will Lastname

Thanks for the tip Landers. I am sorry to say that I am still getting 0
returned.
 
W

Will Lastname

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
 
W

Will Lastname

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top