https://demos.telerik.com/aspnet-mvc/grid/foreignkeycolumn
In addition to the Foreign Key editor template, populate a list which holds all the categories and pass it via the ViewData - you can see how this is done in the ForeignKeyColumnController.cs PopulateCategories()
method.
On the above page, the above statement is made. Other than the function call to PopulateCategories() I don't ever see the actual code run in the function shown anywhere. Can someone please add that code and/or point me to my misunderstanding?
Thank you.
Court Harris
Equity Residential
Hello Court,
Thank you for pointing out the missing method in the provided Demo! The code will be added.
Here is the actual method implementation:
private void PopulateCategories()
{
using (var dataContext = new SampleEntitiesDataContext())
{
var categories = dataContext.Categories
.Select(c => new CategoryViewModel
{
CategoryID = c.CategoryID,
CategoryName = c.CategoryName
})
.OrderBy(e => e.CategoryName);
ViewData["categories"] = categories.ToList();
ViewData["defaultCategory"] = categories.First();
}
}
Kind Regards, Silviya Stoyanova Progress Telerik