3 posts, 0 answers
  1. Louis
    Louis avatar
    40 posts
    Member since:
    Jun 2011

    Posted 03 Feb 2014 Link to this post


    Can you give me a complete example for dropdownlist in the editortemplates?

    For now I have to change all my dropdownlist in every views like this and I Wonder if it's possible to define a generic way in EditorTemplates?

        .Name("NoRisque") // Name of the widget should be the same as the name of the property
        .DataValueField("Value") // The value of the dropdown is taken from the EmployeeID property
        .DataTextField("Text") // The text of the items is taken from the EmployeeName property
        .BindTo((SelectList)ViewBag.NoSource) // A list of all employees which is populated in the controller
  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 05 Feb 2014 Link to this post

    Hi Louis,

    You can use the DropDownFor overload:


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

    Then the name of the widget will be induced from the model of the editor template.

    Atanas Korchev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET AJAX banner
  4. Louis
    Louis avatar
    40 posts
    Member since:
    Jun 2011

    Posted 07 Feb 2014 in reply to Atanas Korchev Link to this post

    Thank you Atanas,

    In fact I complete your answer because I use ViewBag in my controller :

    ViewBag.NoSource = new SelectList(db.Sources, "NoSource", "DescriptionSource_fr");

    to populate the dropdownbox
    @model object
    Html.Kendo().DropDownListFor(model => model)
Back to Top