Hello
I have two tables, products and portalproduct.
These tables are linked by productID. The portal products table has an order column. In my repeater I want to show the productname and other product details from the product table and order from the portalproduct table.
Below is how I create my entity collection
EntityCollection products = new EntityCollection(new ProductEntityFactory());
RelationPredicateBucket bucket = new RelationPredicateBucket();
SortExpression sorter = new SortExpression(PortalProductFields.Order | SortOperator.Ascending);
IPredicateExpression filter = new PredicateExpression();
filter.Add(PortalProductFields.PortalId == PortalID);
IEntityRelation relation = new EntityRelation();
relation.AddEntityFieldPair(ProductFields.Id, PortalProductFields.ProductId);
bucket.PredicateExpression.Add(filter);
bucket.Relations.Add(relation);
using (DataAccessAdapter adapter = new DataAccessAdapter()) {
adapter.FetchEntityCollection(products, bucket, 0, sorter);
}
and here is my repeater:
asp:Repeater runat="server" ID="rptProducts">
<ItemTemplate>
<div class="descblock">
</div>
<table width="100%" cellspacing="5">
<tr>
<td style="width:150px" align="center">
<asp:ImageButton CausesValidation="false" runat="server" ID="imgProductImg"
ImageUrl='<%# String.Format("~/Images/Products/{0}", DataBinder.Eval ( Container.DataItem, "Image")) %>' OnCommand="Proceed" CommandArgument='<%# DataBinder.Eval ( Container.DataItem, "ID") %>'/>
</td>
<td>
<span class="title"><strong><%# DataBinder.Eval ( Container.DataItem, "Name") %></strong></span><br /><br />
<%# DataBinder.Eval ( Container.DataItem, "Description") %>
</td>
<td style="width:100px" align="center" >
<asp:ImageButton CausesValidation="false" runat="server"
ID="imgMoveUp" OnCommand="Move" ImageUrl="~/images/ArrowU.gif" CommandArgument='<%# DataBinder.Eval ( Container.DataItem, "ID") + "," + DataBinder.Eval ( Container.DataItem, "PortalProduct.Order") %>'
/><br />
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
I know I am obviously doing something wrong as I get the following error, but I can't work our what:
DataBinding: 'HelperClasses.EntityCollection`1[[EntityClasses.PortalProductEntity, EntityLayer, Version=0.0.1.0, Culture=neutral, PublicKeyToken=5a6e058bae69689a]]' does not contain a property with the name 'Order'.
Please help, or point me in the direction of an example that shows me how to do this...
Thanks
Bex