1
我想顯示一個網格視圖控件中的導航屬性的字段值。 我的實體是相冊和照片,照片實體必須與相冊實體相關聯。如何在GridView控件中顯示導航屬性?
我想顯示一個相冊的名稱,但它從來沒有顯示在gridview控件中。
以下是我的標記:
<h4>
<asp:DropDownList ID="ddlAlbums" runat="server" Style="padding: 3px; width: 150px;"
AutoPostBack="True">
</asp:DropDownList>
</h4>
<br />
<asp:UpdatePanel ID="pnlPhotos" runat="server" >
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlAlbums" />
</Triggers>
<ContentTemplate>
<asp:DataList ID="PhotosDataList" runat="server" DataKeyField="PhotoID" DataSourceID="PhotosEntityDataSource"
RepeatDirection="Horizontal" CssClass="view" RepeatColumns="5"
onitemdatabound="PhotosDataList_ItemDataBound">
<ItemTemplate>
<asp:Image ID="img" CssClass="thumbnail" ToolTip='<%#Eval("Title")%>' runat="server"
ImageUrl='<%#Eval("Caption","~/Uploads/Pictures/{0}")%>' />
<br />
**<asp:Label ID="lblAlbumName" runat="server" Text='<%#Eval("Album.Name")%>'></asp:Label>**
<asp:LinkButton ID="lnkEdit" runat="server" CommandName="Select" CommandArgument='<%#Eval("PhotoID")%>'
OnClick="lnkEdit_Click">edit</asp:LinkButton>
<asp:LinkButton ID="lnkDelete" runat="server" CommandArgument='<%#Eval("PhotoID")%>'
OnClick="DelPhoto_Click">delete</asp:LinkButton>
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
</asp:UpdatePanel>
<asp:EntityDataSource ID="PhotosEntityDataSource" runat="server" ContextTypeName="Misagh.DAL.MisaghSchoolEntities"
EnableDelete="True" EntitySetName="Photos" Where="it.AlbumID = @AlbumID">
<WhereParameters>
<asp:ControlParameter ControlID="ddlAlbums" DefaultValue="0" DbType="Int32" PropertyName="SelectedValue"
Name="AlbumID" />
</WhereParameters>
</asp:EntityDataSource>
我真的appriciated任何幫助
感謝
能否請您出示的照片類代碼? – Andrei