Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML.SelectListFor selectedValue never gets set
    primarykey
    data
    text
    <p><strong>I have the following partial view which renders a drop down list:</strong></p> <pre><code> @model MartinDog.Core.Models.Section @{ @Html.DropDownListFor(x=&gt;x.Name , new SelectList(Model.Dock.DockTemplate.Columns, "Id", "FriendlyName", Model.DockTemplateColumn.Id.ToString()) , new { @id = "ddlb_dockTemplateColumns" + Model.Id.ToString()}) } </code></pre> <p><strong>I render it on my page like so:</strong></p> <pre><code>@{Html.RenderPartial("_Admin_Page_DockTemplateColumnDropDown", Model);} </code></pre> <p>The partial view is rendered once for every <code>Section</code> object. A Section object one I've created and is editable in a jquery dialog box (change the name, display order, dock template column, etc.)</p> <p>On the test page I am using, this Section dialog box is rendered four times (as there are four of them in my parent object).</p> <p><strong>The problem:</strong> *<strong><em>The SelectedValue in the SelectList for the drop down never gets set</em>*</strong> - that is to say, the correct item in the drop down list is never selected when the dialog is displayed and I can't quite work out why.</p> <p>I thought it might be because the drop down is rendered four times, so I tried rendering it for just one of the 'Sections' but still the same problem.</p> <p>Anyone know what I can do?</p> <p>***edit Not sure if I'm doing it in a sucky way. I had thought of building the dialog just once with jquery and json but I'd prefer to do it this way as it just feels cleaner.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload