Invalid_ViewState on Postback with datagrid

Discussion in 'ASP .Net Datagrid Control' started by TSawyerhm, Aug 2, 2006.

  1. TSawyerhm

    TSawyerhm Guest

    Hello,

    This is an odd one. I have a simple datagrid that is bound to a datatable
    The user gets the results by clicking a Search button. It renders with no
    problems the first time. If they click Search again (the timespan doesn't
    seem to make a difference), it throws Invalid_Viewstate. This happens on a
    production server where SP1 for Framework 1.1 is installed, but does not
    happen on a test server where SP1 has not been installed.

    Here is the call stack minus the viewstate part:

    [FormatException: Input string was not in a correct format.]
    System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo
    info) +0
    System.ComponentModel.Int32Converter.FromString(String value,
    NumberFormatInfo formatInfo) +37

    System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext
    context, CultureInfo culture, Object value) +382

    [Exception: '' is not a valid value for Int32.]

    System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext
    context, CultureInfo culture, Object value) +413

    System.ComponentModel.TypeConverter.ConvertFromString(ITypeDescriptorContext
    context, CultureInfo culture, String text) +12
    System.Drawing.ColorConverter.ConvertFrom(ITypeDescriptorContext context,
    CultureInfo culture, Object value) +975
    System.Web.UI.LosFormatter.ConsumeTypeConverterValue(String token) +220
    System.Web.UI.LosFormatter.DeserializeValueInternal() +1086
    System.Web.UI.LosFormatter.DeserializeValueInternal() +594
    System.Web.UI.LosFormatter.DeserializeValueInternal() +208
    System.Web.UI.LosFormatter.DeserializeValueInternal() +162
    System.Web.UI.LosFormatter.DeserializeValueInternal() +277
    System.Web.UI.LosFormatter.DeserializeValueInternal() +594
    System.Web.UI.LosFormatter.DeserializeValueInternal() +369
    System.Web.UI.LosFormatter.DeserializeValueInternal() +594
    System.Web.UI.LosFormatter.DeserializeValueInternal() +369
    System.Web.UI.LosFormatter.DeserializeValueInternal() +594
    System.Web.UI.LosFormatter.DeserializeValueInternal() +369
    System.Web.UI.LosFormatter.DeserializeValueInternal() +594
    System.Web.UI.LosFormatter.DeserializeValueInternal() +369
    System.Web.UI.LosFormatter.DeserializeValueInternal() +594
    System.Web.UI.LosFormatter.DeserializeValueInternal() +369
    System.Web.UI.LosFormatter.DeserializeValueInternal() +594
    System.Web.UI.LosFormatter.DeserializeValueInternal() +369
    System.Web.UI.LosFormatter.DeserializeValueInternal() +323
    System.Web.UI.LosFormatter.Deserialize(String input) +332
    System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +101

    [HttpException (0x80004005): Invalid_Viewstate
    Client IP: 149.179.232.71
    Port: 2322
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
    ..NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.40607; InfoPath.1)

    Http-Referer:
    http://seam.bpweb.bp.com/HSSEInternalBP/AuditScheduleReport.aspx
    Path: /HSSEInternalBP/AuditScheduleReport.aspx.]
    System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +442
    System.Web.UI.Page.LoadPageViewState() +18
    System.Web.UI.Page.ProcessRequestMain() +447

    '' Is being passed as an arg into ColorConverter. When the datagrid is
    bound, it uses the ItemBound event to set the backcolor of a cell based on
    data in another cell:

    e.Item.Cells(2).BackColor = mycolor.FromName(e.Item.DataItem.Item(3))

    mycolor is a var from System.Drawing.Color

    I know it has something to do with this, but I am confused why this happens
    only on postback and from when LoadPageStateFromPersistenceMedium() is
    called. I don't think page processing is even getting as far as the
    ItemBound event to even call Color.FromName method. When the user clicks
    Search again or even does the sorting, the datasource is repopulated
    everytime ... but the page has to get to that point.

    If I remove the code to look up the color, the ViewState is fine.

    I don't think it's getting as far as the grid events on the postback. Has
    anyone else experienced this? Does it have anything to do with SP1?

    Thanks!
    T
     
    TSawyerhm, Aug 2, 2006
    #1
    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. =?Utf-8?B?Q2hyaXMgU3V0dG9u?=

    Invalid_Viewstate

    =?Utf-8?B?Q2hyaXMgU3V0dG9u?=, Apr 7, 2005, in forum: ASP .Net
    Replies:
    27
    Views:
    1,767
    Huzaifa Tapal
    May 12, 2005
  2. Jennyfer J Barco

    Invalid_Viewstate error again

    Jennyfer J Barco, May 25, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,332
    Alvin Bruney [MVP - ASP.NET]
    Jul 8, 2005
  3. =?Utf-8?B?QXJuZQ==?=

    Invalid_Viewstate

    =?Utf-8?B?QXJuZQ==?=, Aug 30, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    623
    =?Utf-8?B?QXJuZQ==?=
    Aug 31, 2005
  4. =?Utf-8?B?QXJuZQ==?=

    Invalid_Viewstate

    =?Utf-8?B?QXJuZQ==?=, Sep 8, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    685
    =?Utf-8?B?QXJuZQ==?=
    Sep 8, 2005
  5. Ganesh Ramamurthy

    Exception thrown Invalid_Viewstate

    Ganesh Ramamurthy, Dec 2, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    483
    Alvin Bruney - ASP.NET MVP
    Dec 2, 2005
Loading...

Share This Page