Can EntityCollections be displayed in an ASP DataGrid?

Posts   
 
    
cmprogrock
User
Posts: 40
Joined: 16-Nov-2008
# Posted on: 05-Jul-2009 03:19:52   

Can EntityCollections be displayed in an ASP DataGrid?

I'm mapping an EnitiyCollection to a DataGrid & firing DataBind().

Error: System.Reflection.TargetException: Object does not match target type.

Any Ideas? Thanks

http://www.screencast.com/users/chris.m/folders/Jing/media/175686e4-2847-458a-b50f-304a7919fce7

cmprogrock
User
Posts: 40
Joined: 16-Nov-2008
# Posted on: 05-Jul-2009 03:52:30   

Actually - this is not an issue with EntiyCollections (Which are working with DataGrids) It looks like an issue with one of my Entity Objects.

Any clues for ''Object does not match target type'?

Thanks

(This same code is woking in a webservice I have - but not in the WebApp) (I'm reloading all the DLL's to confirm not out of sync)

[TargetInvocationException: Property accessor 'AppId' on object 'AppBreeder.EntityClasses.AppRealtorEntity' threw the following exception:'Object does not match target type.'] System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component) +390

cmprogrock
User
Posts: 40
Joined: 16-Nov-2008
# Posted on: 05-Jul-2009 04:10:57   

It looks like some funny behaviour.

I'm reading that this happens with datagrids when the objects are of different types. I'm bringing back 'App' Entiies - which are the SuperType of many othet objects. (See Function Below)

But in this case - it is all one type...I'm only bring back the AppEtities...so this error should not happen...unless LLBLgen is trying to bring in the SubTypes...Which it looks like its doing

Does LLBLGen bring in the subtypes even when only requesting the SuperTypes?

THE FUNCTION public void FillAppList(int UserId) { EntityCollection<AppEntity> MyApps = null; using (DataAccessAdapter adapter = new DataAccessAdapter()) { LinqMetaData metaData = new LinqMetaData(adapter); var q = from c in metaData.App where c.UserId == UserId orderby c.Title select c;

        MyApps = ((ILLBLGenProQuery)q).Execute<EntityCollection<AppEntity>>();
        this.GridView1.DataSource = MyApps;
        this.GridView1.DataBind();
    }
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Jul-2009 22:23:12   

Please post the exact exception message and stack trace.

(Edit) It may be due to this: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=6812

David Elizondo | LLBLGen Support Team
cmprogrock
User
Posts: 40
Joined: 16-Nov-2008
# Posted on: 05-Jul-2009 23:51:35   

Thanks Daelmo, Yes -that was the issue. I've solved it by using pro quality DataGrid - Telerik. No issues now & looks good. thanks CM