New to Telerik UI for ASP.NET MVCStart a free 30-day trial

Configure ForeignKey Columns with ComboBox Editor in Grids

Environment

ProductTelerik UI for ASP.NET MVC Grid
Product version2025.1.227

Description

How can I configure the foreign-key columns in the Grid to use a ComboBox editor?

Solution

You can achieve this requirement using the following implementation:

  1. Define a foreign-key column in the Grid and specify the name of the View that contains its editor using the EditorTemplateName option:
Razor
columns.ForeignKey(p => p.EmployeeId, (System.Collections.IEnumerable)ViewData["employees"], "EmployeeId", "Name").EditorTemplateName("ComboBox");
  1. Create a View in the ~/Views/Shared/EditorTemplates/ folder with the name ComboBox that contains the ComboBox editor:
Razor
@model object

@(Html.Kendo().ComboBoxFor(m => m)
        .BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
)

To review the complete example, refer to the ASP.NET MVC application on how to configure a foreign-key column in the Grid to use the ComboBox component as an editor.

More ASP.NET MVC Grid Resources

See Also