New to Telerik UI for ASP.NET MVC? Start a free 30-day trial
Configure ForeignKey Columns with ComboBox Editor in Grids
Environment
Product | Telerik UI for ASP.NET MVC Grid |
Product version | 2025.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:
- 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");
- 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
- ASP.NET MVC Grid Documentation
- ASP.NET MVC Grid Demos
- ASP.NET MVC Grid Product Page
- Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)
- Telerik UI for ASP.NET MVC Forums