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

  • Home
  • SEARCH
  • 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 8114927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:18:14+00:00 2026-06-06T03:18:14+00:00

How do you access a strongly bound complex type in a webGrid within MVC

  • 0

How do you access a strongly bound complex type in a webGrid within MVC 3. Example, I have an object called Project that has another object as a property called Employee. The two objects relate to each other on a primary key EmployeeId. If the project is the strongly bound object, how does one access any properties that belong to the employee class that is a property on the Project class?

I have searched around and have found the answer of using dot notation. (Employee.EmployeeId) but that does not work

is there a specific way to do this when binding the columns?

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-06-06T03:18:15+00:00Added an answer on June 6, 2026 at 3:18 am

    The dot notation should work.

    Model:

    public class Project
    {
        public string Name { get; set; }
        public Employee Employee { get; set; }
    }
    
    public class Employee
    {
        public int EmployeeId { get; set; }
    }
    

    Controller:

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            var model = Enumerable.Range(1, 5).Select(x => new Project
            {
                Name = "project " + x,
                Employee = new Employee
                {
                    EmployeeId = x
                }
            });
            return View(model);
        }
    }
    

    View:

    @model IEnumerable<Project>
    
    @{
        var grid = new WebGrid(Model);
    }
    
    @grid.GetHtml(
        columns: grid.Columns(
            grid.Column("Name"),
            grid.Column("Employee.EmployeeId")
        )
    )
    

    Result:

    enter image description here

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

Sidebar

Related Questions

I have a project which uses strongly typed datasets. Let's assume I want to
What is the best way to provide strongly typed access to the session object?
I built a strongly typed session object that looks like this: class MySession {
I have an Access database which has a table with around 6k records. When
I have a strongly recursive function, that creates a (very small) std::multimap locally for
I have a data caller method that returns a SubSonic collection of type ItemDatumCollection.
I have an asp.net nTier application. The data access layer is a strongly typed
I have a strongly typed View that accepts a Customer model, this customer model
I have been saddled with using an in-house data access library that is effectively
In some project we have very that even our staff is not suppose to

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.