Referrencing a property in related table

Referrencing a property in related table

Ryan DraytonRyan Drayton Posts: 2Questions: 2Answers: 0

I have a data model with a foreign key CustomeTypeID. I have used the navigation property to add Included ContayType entity.

var customersQuery = _context.Contacts.Include(c=>c.AgriProgram).Include(c=>c.ContactType).AsQueryable();

the HTML I can access the DisplayName like

<th>@Html.DisplayNameFor(model=>model.Contact[0].ContactType.ContactTypeName)</th>

but the data does not render
{ "name": "ContactTypeName", "data": "ContactTypeName", "targets": 8 }

can someone please me understand what I am doing wrong

Thank you

Answers

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

Sign In or Register to comment.