/ Published in: C#
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//gets product and joins to ProductType to get associated type, then from there to product category to get the category associated with the type. rptProducts.DataSource = db.Products.Include("ProductType.ProductCategory"); rptProducts.DataBind(); //The webform: //Note the use of .eval instead of GetPropertyValue when calling properties that contain nested objects. <tr class="product_row" rel="<%#DataBinder.GetPropertyValue(Container.DataItem, "ProductID") %>"> <td><asp:CheckBox runat="server" ID="chkProduct" /></td> <td><%# DataBinder.Eval(Container.DataItem, "ProductType.ProductCategory.Name") %></td> <td><a href="Edit?id=<%# DataBinder.GetPropertyValue(Container.DataItem, "ProductID") %>"><%# DataBinder.Eval(Container.DataItem, "ProductType.Name") %></a></td> <td><%# DataBinder.GetPropertyValue(Container.DataItem, "DateCreated") %></td> </tr>