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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:58:37+00:00 2026-05-24T08:58:37+00:00

I have a parent table and a child table. Parent Table: int AID, nvarchar

  • 0

I have a parent table and a child table.

Parent Table: int AID, nvarchar parentname, nvarchar description

Child Table: int CID, int AID, nvarchar childname, nvarchar address

Child table has got a foreign key(AID) from parent table. I need to display the list of Child table in view page. I’m new to asp.net mvc and the problem is, I’m not able to get the parentname to be displayed along with the childtable.

As we have foreign key, it should be possible to get the parentname using AID. Can anybody sort it out using some simple example. I’m struggling with this for the last 7hours.

Consider the Parent table to be an account and child to be a list of contacts associated with the account.

Parent Table => PID,PName, PAddress
Child Table => CID,PID,CName,CAddress

Output Table => PName,CName,CAddress

Controller:

public ActionResult list()
{
var listing = db.child.FindContact().ToList();
return view(listing);
}

View snippet(.aspx):

<%: foreach(var a in Model) %>
{
<%: a.PName %>
<%: a.CName %>
<%: a.CAddress %>
}

Thanks.

  • 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-24T08:58:38+00:00Added an answer on May 24, 2026 at 8:58 am

    Your Child object should have a property of type Parent.
    Check this.
    Then you can write a.Parent.PName on the view.

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

Sidebar

Related Questions

I have a parent/child relation table, many to many parentid int not null childid
Say I have two tables, Parent and Child. Parent has a MaxChildren (int) field
If I have a parent table and a child table where there can be
I have a simple parent/child tables. Contract is the parent table. Each contract can
I have db table with parent child relationship as: NodeId NodeName ParentId ------------------------------ 1
I have a table with two child tables. For each record in the parent
I have a table which defines a child-parent relationship between nodes: CREATE TABLE node
In sql server 2005, I have a parent table describing paths, and a child
I have a categories table Category [ID, Title] and a Parent/Child table CategoryParent [ID,CategoryID,ParentCategoryID]
Let's asume I have a parent-child structure setup in SQL (server 2005): CREATE TABLE

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.