Solve Hierarchical One-to-Many Relationship in Dynamic Data Application

How to correctly display the value of a parent-child relationship and also be able to select items on the DropDownList  in ASP.NET Dynamic Data web application?

This method will work with either a recursive or hierarchical relationship between a table and itself, or a relationship between two different tables or entities.

It also works with either Entity Framework or Linq To SQL.

The solution is simple:

Create a partial class of the entity and define a DisplayColumn attribute.

Example:

using System.ComponentModel.DataAnnotations;

namespace Examples
{
    [DisplayColumn("Name")]
    public partial class Category
    {

    }
}

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s