I'm working with Kendo UI on an MVC application. We have a grid and when the user opens the row for editing we have a dropDownList that holds company names. I'm trying to get the DDL to default to the company name that's pertinent to the row.
Here's the column code:
columns.Bound(e => e.company_business_name).Width(220).Title("Company")
.EditorTemplateName("CompanyName");
and here's the editorTemplate code:
@model string
@(Html.Kendo().DropDownListFor(m => m)
.DataTextField("Text")
.DataValueField("Value")</
p
><
p
>
.BindTo((System.Collections.IEnumerable)ViewData["Companies"])
)
and the method that fills the DDL:
private void PopulateCompanies()
{
var companyList = new List<
SelectListItem
>();
if (!string.IsNullOrEmpty(Session["Companies"] as string))
{
companyList = (List<
SelectListItem
>)Session["Companies"];
}
else
{
companyList = new DataAccess().GetCompanies(CurrentSettings.getUser().userId);
CacheCompanies(companyList);
}
ViewData["Companies"] = companyList;
}
The dropDownList is populating, and displays when I click edit, but the selected value is blank. How can I set it to the value that was in the grid when it was in display mode?