Prefetch and DataBinding on DropDownList

Posts   
 
    
varalonga
User
Posts: 7
Joined: 28-Nov-2005
# Posted on: 28-Nov-2005 16:15:52   

Hi all!

I'm having a little problem... rage ~ I want to fill a DropDownList... so far nothing special... problems start when the field I want to bind to DataTextField is not on the root table but on the prefecth one (field "Name" on table "Products"). It seems that fields from the prefetch table can't be accessed (at least directly). Any suggestions (code following):

EntityCollection cfgBColl = new EntityCollection(new ConfigBaseEntityFactory());

ISortExpression sorter = new SortExpression();
sorter.Add(SortClauseFactory.Create(ConfigBaseFieldIndex.Pos, SortOperator.Ascending));

IPrefetchPath2 prefetchPath = new PrefetchPath2((int) EntityType.ConfigBaseEntity);
prefetchPath.Add(ConfigBaseEntity.PrefetchPathProducts);

ctx.Adapter.FetchEntityCollection(cfgBColl, null, 0, sorter, prefetchPath);

cfgBDDL.DataSource = cfgBColl;
cfgBDDL.DataTextField = "Products.Name"; //???
cfgBDDL.DataValueField = "ConfigBaseId";
cfgBDDL.DataBind();

Thanks in advance!

varalonga
User
Posts: 7
Joined: 28-Nov-2005
# Posted on: 28-Nov-2005 17:03:34   

Oh!... I forgot to mention that if a try, e.g., to set "Name" to the DataTextField property I get the following error message:

DataBinder.Eval: 'DX4.ORM.EntityClasses.ConfigBaseEntity' does not contain a property with the name Name.

Paul.Lewis
User
Posts: 147
Joined: 22-Aug-2005
# Posted on: 29-Nov-2005 04:51:12   

In this situation, you'll need to manually bind the dropdown list.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 29-Nov-2005 06:26:08   

A suggestion:

Create a field in the root entity that is mapped to this field (the field on the related entity) (i.e Field mapped on related Field)

You may call it ProductName, and then you can use it in your databindings.