Telerik Extensions for ASP.NET MVC

Version Q1 2012, released 04/19/2012

ForeignKey Column

Order ID
Filter
Employee ID
Filter
Order Date
Filter
Freight
Filter
 
No records to display.
Displaying items 0 - 0 of 0

About this example ASPXRazor

This example shows how to use Telerik Grid for ASP.NET MVC foreign key column to show related data.

The related data should be provided as either SelectList or IEnumerable:

  Html.Telerik().Grid>ClientEditableOrder>()
           .Name("Grid")                      
           .Columns(columns =>
           {
               columns.Bound(o => o.OrderID).Width(100);
               columns.ForeignKey(o => o.EmployeeID, (IEnumerable)ViewData["employees"],
                   "ID", "Name").Width(230);
               columns.Bound(o => o.OrderDate).Width(150);
               columns.Bound(o => o.Freight).Width(220);               
           })                      

When switched to edit mode, by default Telerik DropDownList for ASP.NET MVC will be shown as column editor. This can be changed by modifing the GridForeignKey editor template.

Get more than expected!

Take the Telerik Extensions for ASP.NET MVC to your Visual Studio projects to truly experience their power. Download your free copy now and jumpstart your development with the available learning resources.

The Extensions are offered in both open source and commercial versions the differences between which are well explained in the licensing FAQ.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Other Demos: