Forum:  LLBLGen Pro Runtime Framework

Thread:  ASPxGrid complex databinding


mdbruning (User)   Posted on: 14-Jul-2008 10:32:32.
Hi all,

I'm trying to databind an entity collection to an DevExpress ASPxGrid using complex databinding.

This is the example I found on the the DevExpress website:
Code:

    <dxwgv:ASPxGridView ID="ASPxGridView1" runat="server">
     <Columns>
         <dxwgv:GridViewDataTextColumn Caption="Test" FieldName="CompanyEntity" ReadOnly="True" VisibleIndex="0" >
             <DataItemTemplate>
                 <dxe:ASPxTextBox ID="ASPxTextBox1" runat="server" Text='<%# Eval("CompanyEntity.Name") %>' Width="100%"></dxe:ASPxTextBox>
             </DataItemTemplate>        
         </dxwgv:GridViewDataTextColumn>
     </Columns>
    </dxwgv:ASPxGridView>


However, I get an error that says that the property CompanyEntity does not exist on the OrderEntity. This is related to the [Browsable(false)] attribute, which has been handled in other forum threads as well.

I found a possible solution in which the templates had to be modified, in order to set the Browsable attribute to true. However, when I do this, I get the following exception:

Het type ExtraVestiging.Data.Injectables.Validators.GeneralValidator in assembly ExtraVestiging.Data.Injectables, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null is niet als serialiseerbaar gemarkeerd.
Beschrijving: Er is een onverwerkte uitzondering opgetreden tijdens het uitvoeren van de huidige webaanvraag. Raadpleeg de stacktracering voor meer informatie over deze fout en de oorsprong ervan in de code.

Details van uitzondering: System.Runtime.Serialization.SerializationException: Het type ExtraVestiging.Data.Injectables.Validators.GeneralValidator in assembly ExtraVestiging.Data.Injectables, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null is niet als serialiseerbaar gemarkeerd.

Fout in bron:

Er is een onverwerkte uitzondering gegenereerd tijdens het uitvoeren van de huidige webaanvraag. Aan de hand van de onderstaande tracering van de uitzonderingsstack kunt u meer informatie verkrijgen over de oorsprong en de locatie van de uitzondering.

Stacktracering:

[SerializationException: Het type ExtraVestiging.Data.Injectables.Validators.GeneralValidator in assembly ExtraVestiging.Data.Injectables, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null is niet als serialiseerbaar gemarkeerd.]
System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +2700482
System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +245
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() +88
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) +175
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) +50
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +460
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +489
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +131
DevExpress.Data.IO.TypedBinaryWriter.WriteObject(Object value) +954
DevExpress.Web.Data.WebDataProviderBase.SaveDataRow(TypedBinaryWriter writer, List`1 columns, Int32 visibleIndex) +262
DevExpress.Web.Data.WebDataProviderBase.SaveVisibleRow(TypedBinaryWriter writer, List`1 columns, Int32 visibleIndex, Int32 visibleStartIndex, Int32 pageSize) +388
DevExpress.Web.Data.WebDataProviderBase.SaveVisibleRows(TypedBinaryWriter writer, List`1 savedColumns, Int32 visibleStartIndex, Int32 pageSize) +43
DevExpress.Web.Data.WebDataProviderBase.SaveData(List`1 usedFields, Int32 visibleStartIndex, Int32 pageSize) +361
DevExpress.Web.ASPxGridView.ASPxGridView.OnAfterCreateControlHierarchy() +96
DevExpress.Web.ASPxGridView.Rendering.GridViewContainerControl.PrepareControlHierarchy() +21
DevExpress.Web.ASPxClasses.ASPxWebControlBase.BeforeRender() +46
DevExpress.Web.ASPxClasses.ASPxWebControlBase.Render(HtmlTextWriter writer) +35
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.WebControls.TableCell.RenderContents(HtmlTextWriter writer) +97
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
DevExpress.Web.ASPxClasses.Internal.InternalTableCell.Render(HtmlTextWriter writer) +34
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +7
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
DevExpress.Web.ASPxClasses.Internal.InternalTableRow.Render(HtmlTextWriter writer) +34
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.WebControls.Table.RenderContents(HtmlTextWriter writer) +536
DevExpress.Web.ASPxClasses.Internal.InternalTable.RenderContents(HtmlTextWriter writer) +36
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
DevExpress.Web.ASPxClasses.Internal.InternalTable.Render(HtmlTextWriter writer) +34
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +7
DevExpress.Web.ASPxClasses.ASPxWebControlBase.RenderInternal(HtmlTextWriter writer) +43
DevExpress.Web.ASPxClasses.ASPxWebControl.RenderInternal(HtmlTextWriter writer) +47
DevExpress.Web.ASPxClasses.ASPxWebControlBase.Render(HtmlTextWriter writer) +47
DevExpress.Web.ASPxGridView.ASPxGridView.Render(HtmlTextWriter writer) +57
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +59
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +68
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +37
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Page.Render(HtmlTextWriter writer) +26
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2558


Any ideas on why this exception is thrown? It looks like the issue is related to the modification in the template, because reverting to the original template will not throw the exception anymore. Although than the complex databinding would not work anymore...

Thanks in advance!

Greets Mathieu
Walaa (Support Team)   Posted on: 14-Jul-2008 11:12:04.
Revert to the original templates and try the following:

Code:
    <dxwgv:ASPxGridView ID="ASPxGridView1" runat="server">
     <Columns>
         <dxwgv:GridViewDataTextColumn Caption="Test" FieldName="CompanyEntity" ReadOnly="True" VisibleIndex="0" >
             <DataItemTemplate>
                 <dxe:ASPxTextBox ID="ASPxTextBox1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"CompanyEntity.Name") %>' Width="100%"></dxe:ASPxTextBox>
             </DataItemTemplate>        
         </dxwgv:GridViewDataTextColumn>
     </Columns>
    </dxwgv:ASPxGridView>


mdbruning (User)   Posted on: 14-Jul-2008 11:23:12.
Same problem still exists...
Walaa (Support Team)   Posted on: 14-Jul-2008 14:24:22.
Please check the following discussion:
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=11239

Also please translate the following exception to English.

Quote:
Het type ExtraVestiging.Data.Injectables.Validators.GeneralValidator in assembly ExtraVestiging.Data.Injectables, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null is niet als serialiseerbaar gemarkeerd.
Beschrijving: Er is een onverwerkte uitzondering opgetreden tijdens het uitvoeren van de huidige webaanvraag. Raadpleeg de stacktracering voor meer informatie over deze fout en de oorsprong ervan in de code.

Details van uitzondering: System.Runtime.Serialization.SerializationException: Het type ExtraVestiging.Data.Injectables.Validators.GeneralValidator in assembly ExtraVestiging.Data.Injectables, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null is niet als serialiseerbaar gemarkeerd.

Fout in bron:

Er is een onverwerkte uitzondering gegenereerd tijdens het uitvoeren van de huidige webaanvraag. Aan de hand van de onderstaande tracering van de uitzonderingsstack kunt u meer informatie verkrijgen over de oorsprong en de locatie van de uitzondering.


mdbruning (User)   Posted on: 14-Jul-2008 14:39:18.
Thanks for the reply. I already red that other post before which tells me to:
- Create fields mapped on related fields for all entities
or
- Remove the browsable property from the template

I think, the first option isn't really an option, because our grids are highly customizable, and it's nearly impossible to create fields mapped on related fields for all the entities.

The second throws the exception:

The type ExtraVestiging.Data.Injectables.Validators.GeneralValidator in assembly ExtraVestiging.Data.Injectables, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null is not marked is serializable.
Walaa (Support Team)   Posted on: 14-Jul-2008 15:19:03.
What about translating the above mentioned exception?

Otis (LLBLGen Pro Team)   Posted on: 14-Jul-2008 18:32:48.
Quote:

Details van uitzondering: System.Runtime.Serialization.SerializationException: Het type ExtraVestiging.Data.Injectables.Validators.GeneralValidator in assembly ExtraVestiging.Data.Injectables, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null is niet als serialiseerbaar gemarkeerd.

== ExtraVestiging.Data.Injectables.Validators.GeneralValidator isn't serializable.

So you should add a [Serializable] attribute to this class, as the entity it's injected in is serialized. (into the viewstate, by ASP.NET)

Also, about the browsable attribute, if you want to have this removed during code generation, upgrade to v2.6, it contains a setting to remove these.
JimFoye (User)   Posted on: 16-Jul-2008 17:04:45.
No need to translate the exception when the lead developer speaks Dutch. Cool