我正在尝试将外键表数据字段分配给gridview。它低于错误。
名称为“Dim_Hierarchy.Business_Unit_Name”的字段或属性 未在所选数据源中找到。
Public Function GetInitiativeDataList(ByVal client_Idx As Integer) As List(Of Fact_Initiative)
Dim fact_Initiative As IList(Of Fact_Initiative)
Dim SGAEntities As New SGATLEntities()
fact_Initiative = (From factInitiative In SGAEntities.Fact_Initiative Where factInitiative.Client_Idx = client_Idx).ToList()
Return fact_Initiative
End Function
<asp:GridView ID="gvInitiavtives" runat="server" Width="100%" CssClass="Grid"
RowStyle-Width="30px" AutoGenerateColumns="false" HeaderStyle-CssClass="GridHeader" RowStyle-CssClass="GridItem" AlternatingRowStyle-CssClass="GridAltItem">
<Columns>
<asp:BoundField DataField="Dim_Hierarchy.Business_Unit_Name" HeaderText="" HeaderStyle-Wrap="false" HeaderStyle-HorizontalAlign="NotSet" />
<asp:BoundField DataField="Dim_Hierarchy.Business_Unit_Function" HeaderText="" HeaderStyle-Wrap="false" HeaderStyle-HorizontalAlign="NotSet" />
......
......
我是以正确的方式做的吗?
答案 0 :(得分:0)
由于您喜欢使用Entity Framework
。 Aspx
有EntityDatasource
,并且为了挂钩相关表,模型构建的每个导航属性都有Include
属性。 Entity Tutorial。然后您的Binding看起来像:
asp:TemplateField...
asp:Label Text='<%# Eval("tablename.fieldname") %>...