ASP.Net/VS2005 EntityCollection and Repeater

Posts   
 
    
glennpd
User
Posts: 30
Joined: 09-Feb-2006
# Posted on: 12-Feb-2006 20:19:49   

Does anyone have an example of Databinding and formating of a repeater from an entityColleciton. I am very new to this and am at a loss for a technique. Unfortunately the docs do not show an ASP example.

Thanks

Glenn

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39930
Joined: 17-Aug-2003
# Posted on: 12-Feb-2006 21:00:17   

what have you tried yourself which failed? if I have an EntityCollection with CustomerEntity instances, I can do in the repeatercontrol: <%#((CustomerEntity)Container.DataItem).CustomerID%> etc. (add an imports to the namespace which contains the entity classes to the top of the aspx page)

Frans Bouma | Lead developer LLBLGen Pro
glennpd
User
Posts: 30
Joined: 09-Feb-2006
# Posted on: 12-Feb-2006 21:26:30   

I do not understand the syntax you presented.flushed What I have is an EntityCollection named Contacts, and an Entity Contact and a Repeater named Repeater1. In VB.Net would I code this as:

Dim _Contact as Contact
Dom _Contacts as contacts
_contacts.GetMulti(nothing)
...
...
...

<asp:Repeater ID="Repeater1" runat="server">
          <ItemTemplate>
             <tr>
                <td> <%=((Contact)Dataitem.LastName)%></td>
             </tr>
          </ItemTemplate>
</asp:Repeater>
...
...
...
</body>

Thanks

Glenn

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39930
Joined: 17-Aug-2003
# Posted on: 12-Feb-2006 21:39:49   

You should use <%# ... %> syntaxis to bind in asp.net, not <%= ... %> Could you try:


<asp:Repeater ID="Repeater1" runat="server">
         <ItemTemplate>
             <tr>
                <td> <%#(CType(Dataitem, Contact).LastName)%></td>
             </tr>
         </ItemTemplate>
</asp:Repeater>

instead?

Frans Bouma | Lead developer LLBLGen Pro