Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6076483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:36:46+00:00 2026-05-23T10:36:46+00:00

I have the following partial view which renders a drop down list: @model MartinDog.Core.Models.Section

  • 0

I have the following partial view which renders a drop down list:

 @model MartinDog.Core.Models.Section
 @{
    @Html.DropDownListFor(x=>x.Name
                          , new SelectList(Model.Dock.DockTemplate.Columns, 
                              "Id", "FriendlyName", 
                               Model.DockTemplateColumn.Id.ToString())
                          , new { @id = "ddlb_dockTemplateColumns" + 
                               Model.Id.ToString()})    
 }

I render it on my page like so:

@{Html.RenderPartial("_Admin_Page_DockTemplateColumnDropDown", Model);}

The partial view is rendered once for every Section 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.)

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

The problem:
*The SelectedValue in the SelectList for the drop down never gets set* – 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.

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.

Anyone know what I can do?

***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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:36:47+00:00Added an answer on May 23, 2026 at 10:36 am

    Doh… fixed – totally my own fault.

    I had set up my html.dropdownlistfor like so
    @Html.DropDownListFor(x=>x.Name,

    When it should’ve been like so:
    @Html.DropDownListFor(x=>x.DockTemplateColumn.Id,

    Setting the first argument to x=>x.DockTemplateColumn.Id (which uniquely identifies the items in my list) instead of x.Name fixed the issue straight away.

    Just thought I’d post it here in case someone else makes the same mistake I did.

    edit
    Found the answer here:
    C# mvc 3 using selectlist with selected value in view

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in a partial view I have the following: <%Html.RenderAction(MVC.User.GetComments(Model.UserGroupName)); %> can I render a
I have the following form in a partial view @model PartDetail @using (Ajax.BeginForm(Create, Part,
I have the following view model: Public Class MyViewModel Public Property SelectedIDs As List(Of
I have the following code in a partial view (using Spark): <span id=selectCount>0</span> video(s)
I have a partial that renders a select box using the following method: <%=
Imagine I have the following 'partial' which is generated through a bunch of views:
I have a view model for a view which displays multiple forms on the
I have the following code: public partial class queryTerm : System.Web.UI.UserControl { private static
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have this view: new.html.haml %h1 New account - form_for @user do |f| =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.