ViewState Question

Discussion in 'ASP .Net' started by Sparky Arbuckle, Mar 6, 2005.

  1. 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.
     
    Sparky Arbuckle, Mar 6, 2005
    #1
    1. Advertising

  2. 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
     
    Jeffrey Palermo, Mar 6, 2005
    #2
    1. Advertising

  3. 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:...
    > 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.
    >
     
    Ken Dopierala Jr., Mar 6, 2005
    #3
  4. 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.
     
    Sparky Arbuckle, Mar 6, 2005
    #4
  5. Thanks Ken and Jeffrey. I will look more into the problem.
     
    Sparky Arbuckle, Mar 6, 2005
    #5
    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:
    542
    Ben Rush
    Dec 5, 2003
  2. Steph
    Replies:
    2
    Views:
    1,682
    heislord5
    May 11, 2011
  3. ujjc001
    Replies:
    0
    Views:
    1,385
    ujjc001
    Jul 27, 2005
  4. sck10
    Replies:
    6
    Views:
    929
    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:
    293
Loading...

Share This Page