Hello, I am using entity framework. My model has entity tblGameInfo where in navigation properties are associations called tblPlayer1 and tblPlayer2 which links to entity tblPlayer. I have listview on my page where I want to show game info with players names. I have found that in of listview I should have e.g. one of those:
<td>
<asp:Label ID="tblPlayer1Label" runat="server"
Text='<%# Eval("tblPlayer1.FirstName")%>' />
</td>
<td>
<asp:Label ID="tblPlayer2Label" runat="server"
Text='<%# GetPlayerName(Eval("tblPlayer2.id")) %>' />
</td>
But it does not work. I got nothing displayed in a listview. I have tried many different options but cannot find working one. Probably is some simple mistake but I am new to asp.net and cannot find it. Second problem with this is editing. In edit template there is dropdownlist with all players.
<td>
<asp:DropDownList ID="DropDownList1" runat="server"
DataTextField="FullName"
DataValueField="id"
SelectedValue='<%# Bind("tblPlayer2") %>'> <- ??
</asp:DropDownList>
</td>
How do I databind it? It is not allowed to bind and change properties? It writes me that element does not exist on a list of elements.