Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can i display a navigation property in a gridview control?
    primarykey
    data
    text
    <p>I want to display a field value from a navigation property in a grid view control. My entities are Albums and Photos and a Photo entity must be associated with an Album entity.</p> <p>I want to display an albums’s name but it is never shown in the gridview control.</p> <p>The following is my markup:</p> <pre><code>&lt;h4&gt; &lt;asp:DropDownList ID="ddlAlbums" runat="server" Style="padding: 3px; width: 150px;" AutoPostBack="True"&gt; &lt;/asp:DropDownList&gt; &lt;/h4&gt; &lt;br /&gt; &lt;asp:UpdatePanel ID="pnlPhotos" runat="server" &gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID="ddlAlbums" /&gt; &lt;/Triggers&gt; &lt;ContentTemplate&gt; &lt;asp:DataList ID="PhotosDataList" runat="server" DataKeyField="PhotoID" DataSourceID="PhotosEntityDataSource" RepeatDirection="Horizontal" CssClass="view" RepeatColumns="5" onitemdatabound="PhotosDataList_ItemDataBound"&gt; &lt;ItemTemplate&gt; &lt;asp:Image ID="img" CssClass="thumbnail" ToolTip='&lt;%#Eval("Title")%&gt;' runat="server" ImageUrl='&lt;%#Eval("Caption","~/Uploads/Pictures/{0}")%&gt;' /&gt; &lt;br /&gt; **&lt;asp:Label ID="lblAlbumName" runat="server" Text='&lt;%#Eval("Album.Name")%&gt;'&gt;&lt;/asp:Label&gt;** &lt;asp:LinkButton ID="lnkEdit" runat="server" CommandName="Select" CommandArgument='&lt;%#Eval("PhotoID")%&gt;' OnClick="lnkEdit_Click"&gt;edit&lt;/asp:LinkButton&gt;&amp;nbsp; &lt;asp:LinkButton ID="lnkDelete" runat="server" CommandArgument='&lt;%#Eval("PhotoID")%&gt;' OnClick="DelPhoto_Click"&gt;delete&lt;/asp:LinkButton&gt; &lt;/ItemTemplate&gt; &lt;/asp:DataList&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;asp:EntityDataSource ID="PhotosEntityDataSource" runat="server" ContextTypeName="Misagh.DAL.MisaghSchoolEntities" EnableDelete="True" EntitySetName="Photos" Where="it.AlbumID = @AlbumID"&gt; &lt;WhereParameters&gt; &lt;asp:ControlParameter ControlID="ddlAlbums" DefaultValue="0" DbType="Int32" PropertyName="SelectedValue" Name="AlbumID" /&gt; &lt;/WhereParameters&gt; &lt;/asp:EntityDataSource&gt; </code></pre> <p>I would really appriciated any help</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload