DropDownListFor SelectedIndex

2 posts, 0 answers
  1. Nathan
    Nathan avatar
    4 posts
    Member since:
    Oct 2016

    Posted 09 Nov 2016 Link to this post

    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")

    and here's the editorTemplate code:


    @model  string
    @(Html.Kendo().DropDownListFor(m => m)

    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"];
                companyList = new DataAccess().GetCompanies(CurrentSettings.getUser().userId);
            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?

  2. Ivan Danchev
    Ivan Danchev avatar
    1301 posts

    Posted 11 Nov 2016 Link to this post

    Hello Nathan,

    We would suggest you to check the explanation and example Igorrious provides in this thread, which discusses a similar scenarios. Make sure the DropDownList's Name matches the column's name (or if you prefer to use the DropDownListFor helper to set the model properly: DropDownListFor(m => m.company_business_name)

    Ivan Danchev
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Back to Top