473,473 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Viewstate Disappearance

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?

Nov 19 '05 #1
7 1248
You need to add your variable first.

viewstate.Add("ID", 0)

Landers
"Will Lastname" <wh****@brinkster.net> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
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?

Nov 19 '05 #2
Thanks for the tip Landers. I am sorry to say that I am still getting 0
returned.

Nov 19 '05 #3

when are you adding variable to viewstate?

"Will Lastname" <wh****@brinkster.net> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Thanks for the tip Landers. I am sorry to say that I am still getting 0
returned.

Nov 19 '05 #4
and when are you reading it?

"Joe Dotnet" <no@spam.com> wrote in message
news:eK**************@TK2MSFTNGP14.phx.gbl...

when are you adding variable to viewstate?

"Will Lastname" <wh****@brinkster.net> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Thanks for the tip Landers. I am sorry to say that I am still getting 0
returned.


Nov 19 '05 #5
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

Nov 19 '05 #6

ok, and where it is in page lifecycle?

"Will Lastname" <wh****@brinkster.net> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
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

Nov 19 '05 #7
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.

Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
10
by: neo | last post by:
hi, I am studying ASP.NET and have few questions - 1) The session ID and values of controls is stored in VIEWSTATE variable. So now when we put EnableViewState="false" in Page directive and...
1
by: Simon | last post by:
Hi everyone, I have a quick question that I hope someone can help me with: I've made a user control that contains a text box and some validation functionality. This control has a few extra...
7
by: et | last post by:
I'm not sure I understand the use of the ViewState. Do I understand correctly that values of controls are automatically held in a hidden control called ViewState? If so, then why can't we get...
3
by: RCS | last post by:
I have an app that I have different "sections" that I want to switch back and forth from, all while having the server maintain viewstate for each page. In other words, when I am on Page1.aspx and...
9
by: Mark Broadbent | last post by:
Been a while since I've touched asp.net but one thing that always seems to fustrate me is the loss of state on variable declarations. Is there anyway (i.e. assigning an attribute etc) to instruct...
6
by: hitendra15 | last post by:
Hi I have created web user control which has Repeater control and Linkbutton in ItemTemplate of repeater control, following is the code for this control On first load it runs fine but when...
12
by: Nick C | last post by:
Hi How can i reduce the viewstate for my asp.net application. It is getting very large now. What is a good solution? thanks N
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.