Binding Dropdownlist in ClientDetailTemplate

2 posts, 0 answers
  1. Gabriell
    Gabriell avatar
    3 posts
    Member since:
    Mar 2014

    Posted 25 May 2016 Link to this post

    This really should be a minor but i cannot get it to work

    I need to bind to a value (StatusId) from the parent row in my DropDownList


    In my clientDetailTemplate i have

    var parmStatusId = new HtmlString("#: StatusId #");
    @Html.TextBox("txtBox", parmStatusId)  //this works just fine

    @Html.DropDownList("myDropDownList", new SelectList(Model.StatusList, "Value", "Text", parmStatusId), string.Empty, new { @class = "form-control" }); //this doesnt work :-(


    The source from the above is as following


    <input id="txtBox" name="txtBox" type="text" value="#: StatusId #" />

    <select class="form-control" name="1"><option value=""></option>
    <option value="1">Ubehandlet</option>
    <option value="2">Behandlet</option>
    <option value="3">Lukket</option>


    Am i missing the obvious??

  2. Rosen
    Rosen avatar
    3253 posts

    Posted 30 May 2016 Link to this post

    Hello Jesper,

    Such approach will not work as the DropDownList helper will try to select the option on the server where the client-side template expression is not evaluated. Thus, no item will be selected.

    Instead you could use the DetailInit event to set the value on the client-side. Similar to the following:

        function detailInit(e) {

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top