Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7657001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:54:48+00:00 2026-05-31T12:54:48+00:00

.NET 4 ASP.NET I have a DetailsView that is displaying an entity framework record

  • 0

.NET 4 ASP.NET

I have a DetailsView that is displaying an entity framework record for a table that has a linked lookup table. I have an asp:BoundField with the datafield set as “linkedTable.Field” and it displays a value.

<asp:BoundField DataField="linkedTable.Field" HeaderText="linkedTable.Field" 
            SortExpression="linkedTable.Field" />

I am trying to use that value in an asp:TemplateField but when I try to get it using:

<asp:TemplateField HeaderText="Field" SortExpression="linkedTable.Field" >
   <EditItemTemplate>
     <asp:Label runat="server" ID="lblField" Text='<%# Bind("linkedTable.Field") %>' />
   </EditItemTemplate>
</asp:TemplateField>

Nothing shows up in the label. I can change the Bind() to a field that is not part of the linked table and it works (i.e. the “ID” field). My problem is I don’t understand why the linkedtable.Field value shows up in one context and not in the other.

FYI, my data connection is a EntityDataSource

<asp:EntityDataSource ID="edsNYSEDaily" runat="server" 
    ConnectionString="name=ServerDBEntities" 
    DefaultContainerName="ServerDBEntities" EntitySetName="tblNYSE" 
    EntityTypeFilter="tblNYSE" EnableUpdate="True" EnableFlattening="true"
    AutoGenerateWhereClause="True" Select="" Where="">
    <WhereParameters>
        <asp:QueryStringParameter DefaultValue="0" Name="ID" 
            QueryStringField="ID" Type="Int32" />
    </WhereParameters>

Let me know if you need any other information. I am stuck

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:54:49+00:00Added an answer on May 31, 2026 at 12:54 pm

    Ok, discovered the problem:
    Needed to add Include="linkedTable" to the EntityDataSource tag. Still not sure why it was even working in the <asp:DataBound /> tag.

    Source for the answer: forums.asp.net

    Copy of the text:

    you should start here: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.entitydatasource.include.aspx

    notice that, you won’t be able to Bind (I mean two-way data-binding) the related entities (see the remarks there).

    and, you’d have to use a TemplateField for those properties.

    see this example (I used the link table ‘TableAB’ for EntitySetName and included the other two):

        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="EntityDataSource1">
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
                <asp:BoundField DataField="IDA" HeaderText="IDA" SortExpression="IDA" />
                <asp:BoundField DataField="IDB" HeaderText="IDB" SortExpression="IDB" />
                <asp:TemplateField HeaderText="TableA Name">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("TableA.NameA") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="TableB Name">
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Eval("TableB.NameB") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=ABLinkEntities"
            DefaultContainerName="ABLinkEntities" EnableDelete="True" EnableFlattening="False"
            EnableInsert="True" EnableUpdate="True" EntitySetName="TableABs" Include="TableA,TableB">
        </asp:EntityDataSource>
    

    you’ll have to re-consider the updates and deletes, you could do them manually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a DetailsView in ASP.NET that gets data from the database based
I have a asp.net detailsview control on a page. I've noticed that it always
Say you have something like an ASP.NET ASP:DetailsView to show and edit a single
I have asp.net form that contains fields. When I access this window, my javascript
I have ASP.NET page with an iframe on it for displaying some pdf reports
For ASP.NET, I'm using a DetailsView for insert and edit of a record. For
Am using VS2008 ASP.Net Web Forms have a detailsview, databound to web service reference
I have the following detailsview in my asp.net web application. What it should show
i have asp.net application. it has App_Data folder. this folder contain mdf and ldf
I have a User Control with a DetailsView that has the property AutoGenerateRows set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.