ASPxGriView databinding issue

Posts   
 
    
Isz
User
Posts: 108
Joined: 26-Jan-2006
# Posted on: 27-Apr-2008 05:07:35   

Hi all, I am working with the ASPxGridView from devex and also using the LLBLGenProDataSource2. LLBLGen 2.5 9-27-2007. Adapter

When a create an EntityCollection<TopicEntity> and add prefetch to ContentType, on postback I get the following exception:


 The state information is invalid for this page and might be corrupted.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The state information is invalid for this page and might be corrupted.

Source Error:

Line 111:       /// <param name="info"></param>
Line 112:       /// <param name="context"></param>
Line 113:       protected EntityCollection( SerializationInfo info, StreamingContext context )
Line 114:           : base( info, context )
Line 115:       {


Source File: C:\Projects\WebWired_Clients\Iszimation\Code\v1_2\Project\Iszimation.DataEntities.Generic\HelperClasses\EntityCollection.cs    Line: 113

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.GetEntityDescription(Boolean switchFlag, IEntity2 entity) +225
   SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2`1.GetEntityDescription(TEntity entity, Boolean switchFlag) +17
   SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore`1.PerformAdd(T item) +95
   SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore`1..ctor(SerializationInfo info, StreamingContext context) +417
   SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2`1..ctor(SerializationInfo info, StreamingContext context) +39
   Iszimation.DataEntities.Generic.HelperClasses.EntityCollection`1..ctor(SerializationInfo info, StreamingContext context) in C:\Projects\WebWired_Clients\Iszimation\Code\v1_2\Project\Iszimation.DataEntities.Generic\HelperClasses\EntityCollection.cs:113

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context) +0
   System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context) +24
   System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context) +114
   System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context) +257
   System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder) +49
   System.Runtime.Serialization.ObjectManager.DoFixups() +167
   System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) +203
   System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) +190
   System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream) +12
   System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +1669
   System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +854
   System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +854
   System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +198
   System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363
   System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210
   System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +363
   System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210
   System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +210
   System.Web.UI.ObjectStateFormatter.DeserializeValue(SerializerBinaryReader reader) +198
   System.Web.UI.ObjectStateFormatter.Deserialize(Stream inputStream) +142

[ArgumentException: The serialized data is invalid.]
   System.Web.UI.ObjectStateFormatter.Deserialize(Stream inputStream) +206
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +342
   System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
   System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
   System.Web.UI.HiddenFieldPageStatePersister.Load() +136

[ViewStateException: Invalid viewstate. 
    Client IP: 127.0.0.1
    Port: 2022
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
    ViewState: /wEPDwULLTE1N...]

[HttpException (0x80004005): The state information is invalid for this page and might be corrupted.]
   System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +267
   System.Web.UI.HiddenFieldPageStatePersister.Load() +218
   System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +83
   System.Web.UI.Page.LoadAllState() +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
   System.Web.UI.Page.ProcessRequest() +86
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   ASP.content_secure_default2_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\iszimation\67d5e1ba\f0851312\App_Web_3kotkyiv.1.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

My code behind is something like:


        private void Fetch()
        {
            IDataAccessAdapter a = DataAccessAdapterFactory.CreateStandardAdapter();
            EntityCollection<TopicEntity> t = new EntityCollection<TopicEntity>();

            PrefetchPath2 p = new PrefetchPath2((int)EntityType.TopicEntity);
            IPrefetchPathElement2 prefetchContentType = TopicEntity.PrefetchPathContentType;
            p.Add(prefetchContentType);
            a.FetchEntityCollection(t, null, 0, null, p);
            this.LLBLGenProDataSourceList.EntityCollection = t;
        }
 ...

        protected void LLBLGenProDataSourceList_PerformGetDbCount(object sender, PerformGetDbCountEventArgs2 e)
        {
        }

        protected void LLBLGenProDataSourceList_PerformSelect(object sender, PerformSelectEventArgs2 e)
        {
            this.Fetch();
        }
 ...

When I remove the prefetch, the page performs a postback no problem. So my thought is that perhaps the LLBLGenProDataSource does not retain the prefetch that perhaps the grid needs.

Is there something obvious I am missing, or need to set, or should I not add prefetches when working with ASPxGridViews?

Thanks!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-Apr-2008 20:35:49   

What is the value of these ASPxGridView's properties? EnableViewState EnableRowsCache

What is the value of the LLBLGenProDataSource.CacheLocation property? If possible, attach the declarative ASPX of that page (the relevant part).

(Edit) Check if the error is related to this

David Elizondo | LLBLGen Support Team
Isz
User
Posts: 108
Joined: 26-Jan-2006
# Posted on: 28-Apr-2008 17:54:08   

Hi...

I did find that link you posted about the FF bug and tried working with that, but the exception occurred anyway.

As for the aspx code, the grid view properties you listed are at their defaults.


    <form id="form1" runat="server">
        <dxwgv:ASPxGridView ID="ASPxGridView" runat="server" 
            ClientInstanceName="grid" 
            DataSourceID="LLBLGenProDataSourceList" 
            KeyFieldName="TopicId" 
            OnCustomUnboundColumnData="ASPxGridView_CustomUnboundColumnData"
            OnHtmlRowCreated="ASPxGridView_HtmlRowCreated"
            OnRowCommand="ASPxGridView_RowCommand"
            >
             <Columns>  
                <dxwgv:GridViewDataColumn Caption="Name" FieldName="Name" UnboundType="String">
                  <DataItemTemplate>
                    <asp:LinkButton ID="LinkButtonName" runat="server">Edit</asp:LinkButton>
                  </DataItemTemplate>
                </dxwgv:GridViewDataColumn>
                <dxwgv:GridViewDataColumn FieldName="Active" ReadOnly="true">  
                </dxwgv:GridViewDataColumn>  
             </Columns>
             <Settings  ShowGroupPanel="False" />
       </dxwgv:ASPxGridView> 
        
<llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSourceList" runat="server" 
            DataContainerType="EntityCollection"
            LivePersistence="False"
            EnablePaging="True"
            AllFieldsKeepEmptyStringAsValue=true
            OnPerformGetDbCount="LLBLGenProDataSourceList_PerformGetDbCount"
            OnPerformSelect="LLBLGenProDataSourceList_PerformSelect"
            AdapterTypeName="Iszimation.DataEntities.SqlServerSpecific.DataAccessAdapter, Iszimation.DataEntities.SqlServerSpecific"
            EntityFactoryTypeName="Iszimation.DataEntities.Generic.FactoryClasses.TopicEntityFactory, Iszimation.DataEntities.Generic">
        </llblgenpro:LLBLGenProDataSource2>
    </form>

Isz
User
Posts: 108
Joined: 26-Jan-2006
# Posted on: 28-Apr-2008 17:58:29   

Ok, I also set the LLBLGenProDataSource2.CacheLocation="Session" and it no longer throws the exception, but if set to viewstate then it does.

Perhaps the grid is using session and if the LLBLGenProDataSource2 is using viewstate there is a disconnect. Does this sound like a true statement?

Thanks!

Todd

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Apr-2008 08:24:45   

Hi Todd. I suspected it was related to viewstate/cacheLocation because of this: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=12322

David Elizondo | LLBLGen Support Team