Invalid_ViewState on Postback with datagrid

T

TSawyerhm

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
 

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,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top