Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ViewState Question

Reply
Thread Tools

ViewState Question

 
 
Sparky Arbuckle
Guest
Posts: n/a
 
      03-06-2005
What is wrong with the following syntax?


IF ViewState("CustID") < " " AND gtCart.Count > " " THEN WriteOrder()

The error I get is:

Exception Details: System.FormatException: Input string was not in a
correct format.

 
Reply With Quote
 
 
 
 
Jeffrey Palermo
Guest
Posts: n/a
 
      03-06-2005
Sparky,
Honestly, it could be any number of things. ViewState indexers return
an object, so I would recommend casting it to the expected type before
using, and Count ( I assume ) is an integer, so you have an issue
there, but the exception could have come from the WriteOrder method.
Did you examine the stack trace to determine where the exception came
from? A little debugging and stepping through the code can give you
the exact statement that caused the exception.

Best regards,
Jeffrey Palermo
Blog: http://www.jeffreypalermo.com

 
Reply With Quote
 
 
 
 
Ken Dopierala Jr.
Guest
Posts: n/a
 
      03-06-2005
Hi,

Maybe try this:

If (CStr(ViewState("CustID")).Length > 0) AND (gtCart.Count > 0) Then
WriteOrder()

You appear to be mixing integers and strings. Is the Count property of
gtCart an integer? If so, then the above will work. If it is a string
exchange this: (CStr(gtCart.Count).Length > 0) with this: (gtCart.Count >
0) . Then you should be good to go. Also, put Option Explicit On at the
top of your code file and in VS.Net it should highlight where you are making
dangerous conversions between types. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Sparky Arbuckle" <> wrote in message
news: ups.com...
> What is wrong with the following syntax?
>
>
> IF ViewState("CustID") < " " AND gtCart.Count > " " THEN WriteOrder()
>
> The error I get is:
>
> Exception Details: System.FormatException: Input string was not in a
> correct format.
>



 
Reply With Quote
 
Sparky Arbuckle
Guest
Posts: n/a
 
      03-06-2005
InvalidCastException: Cast from string "" to type 'Double' is not valid

I found that from the stack trace. How do I actually use the stack
trace? That would probably be great information.

 
Reply With Quote
 
Sparky Arbuckle
Guest
Posts: n/a
 
      03-06-2005
Thanks Ken and Jeffrey. I will look more into the problem.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with ViewState: "function 'ViewState.get_Item' evaluated and returned null" Steph ASP .Net 2 05-11-2011 02:35 PM
Errors: Failed to load viewstate. & Validation of viewstate MAC failed. sck10 ASP .Net 6 09-01-2006 05:59 PM
Loading usercontrols, viewstate problem, slighly different from all others "viewstate uc problems" please help... ujjc001 ASP .Net 0 07-27-2005 01:52 PM
Viewstate errors... how do I get viewstate working? mark ASP .Net Building Controls 0 02-20-2004 02:17 PM
Corrupted ViewState (Yes, another issue concerning viewstate) Ben Rush ASP .Net 2 12-05-2003 04:17 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57