All Components
Theme

Themes

    Grid / ForeignKey column

    Drag a column header and drop it here to group by that column
    FilterProduct nameFilterCategoryFilterUnit price 
    seek-warrow-w
    • 1
    arrow-eseek-eNo items to display

    Description

    In this example you can see how to implement foreign key column in the Telerik MVC grid, holding DropDownList editor for data editing. The ForeignKey column definition is shown below:

    columns.ForeignKey(p => p.CategoryID, (System.Collections.IEnumerable)ViewData["categories"], "CategoryID", "CategoryName").Title("Category").Width(150);

    Here is the definition for the DropDownList user control:

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<object>" %>
    <%= Html.Kendo().DropDownListFor(m => m)   
        .BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
    %>

    ASP.NET MVC source

    Also available for:

    • foreignkeycolumn.cshtml
    • ForeignKeyColumnController.cs
    • ProductService.cs

    Support & learning resources

    Grid for other technologies