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 4265816
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:40:31+00:00 2026-05-21T06:40:31+00:00

I have an EntityDataSource I’ve mapped to the entity Resident which includes two navigation

  • 0

I have an EntityDataSource I’ve mapped to the entity Resident which includes two navigation properties (Building1, Room1). I’ve set my GridView to use this EntityDataSource and set the EntityDataSource Include property to Building1, Room1 so it includes these navigation properties and have added these columns to the GridView. When I run the application instead of displaying the associated navigation property it shows this: webHousingAdmin.Building
How can I get it to display the actual value?
Code looks like this for GridView:

        <asp:TemplateField>
            <ItemTemplate>
                <asp:Label ID="lbl1" runat="server" Text='<%# Bind("Building1") %>' />
            </ItemTemplate>
        </asp:TemplateField>

I’ve gotten it to display the actual value by using the following code:

            <asp:TemplateField HeaderText="Building">
            <ItemTemplate>
                <asp:Label ID="lblBuilding" Text='<%# Bind("Building1.building_name") %>' runat="server" />
            </ItemTemplate>
        </asp:TemplateField>

But is there a simpler way to do this? This only displays the text, doesn’t let me edit it…if I can do it as a boundfield that would be ideal.

  • 1 1 Answer
  • 1 View
  • 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-21T06:40:32+00:00Added an answer on May 21, 2026 at 6:40 am

    To get something meaningful in your label you can either bind a scalar property of your Building class to the Label …

    <asp:Label ID="lbl1" runat="server" Text='<%# Bind("Building1.Name") %>' />
    

    … or you can overwrite ToString() of the class …

    public class Building
    {
        public string Name { get; set; }
        public string AnotherText { get; set; }
    
        public override string ToString()
        {
            return string.Concat(Name, ", ", AnotherText); // or whatever you like
        }
    }
    

    If you bind a property to the grid which is a class the binding engine will call ToString() – and this returns only the full class name (namespace dot class name) if you don’t override ToString. This explains why you only see webHousingAdmin.Building in your example.

    Edit

    Not really related to this question: But you might encounter problems if you try to bind navigation properties with Bind (and not only Eval) for bidirectional communication between datasource and grid. Probably it won’t work. See this related question and answer:

    Columns of two related database tables in one ASP.NET GridView with EntityDataSource

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

Sidebar

Related Questions

I have GridView that allows select. It takes data from EntityDataSource . How do
I have a GridView with an EntityDataSource. I want to filter the rows at
I have an EntityDataSource bound to many filters used by gridview data, I want
I use C# in ASP.NET 4. I have a GridView and an EntityDataSource for
I have an Entity Data Model with two entities in it Roles and Users.
I have a GridView that is bound to an Entity Framework object. I want
I have a parent GridView that is bound to an EntityDataSource with a child
I have a gridview that is populated from an entitydatasource in asp.net. In my
I have two drop down lists; the first is bound to an entity datasource,
I have an EntityDataSource: <asp:EntityDataSource ID=EntityDataSourcePersoneel runat=server ConnectionString=name=HotelTestDatabaseEntities DefaultContainerName=HotelTestDatabaseEntities EntitySetName=Personeels Include=Afdeling> </asp:EntityDataSource> I dynamically

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.