Search

ASP.NET MVC - Possible MVC bug when working with EditorTemplates and drop down lists by Philip Fourie

Closed
as Fixed Help for as Fixed

2
0
Sign in
to vote
Type: Bug
ID: 654543
Opened: 3/29/2011 10:54:42 PM
Access Restriction: Public
0
Workaround(s)
1
User(s) can reproduce this bug
In ASP.NET MVC 3 with ASPX

Html.DropDownListFor does not select the correct item from the drop down when used in an Editor Template.

It however works as expected when used 'normally' when not embedded in an Editor Template.
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

Reliability

Steps to reproduce

A repro of the problem can be downloaded here:
http://filegooi.co.za/get2/162a5792df996487577668c4d213554a/MvcDropdownBug.zip

Steps to reproduce:
1. Create a view model containing a complex type (e.g. Address) to be used in an Editor Template. This model should also contain the list to select from. (e.g. Country List)
2. Create an Editor Template that makes use of the Html.DropDownListFor method. (e.g. Country list for an address)
3. Create a view (.ASPX) that points to the Editor Template in step 2. (i.e. Html.EditorFor)
4. In the Controller update the view model to indicate which item should be selected. (e.g. model.CountryCode = "ZAR")
5. Pass in the view model to the view. The incorrect behaviour should be apparent here, as the wrong item is selected (it seems to default to first item in the list).

Side note:
Repeating the above without using and Editor Template works as expected.

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

The model for the country code is set to ZAR but it incorrectly set the value to USA.

Expected results

Setting the model to ZAR should selected ZAR in the drop down.
File Attachments
File Name Submitted By Submitted On File Size  
MvcDropdownBug.zip 3/29/2011 431 KB
Sign in to post a comment.
Posted by Microsoft on 5/23/2011 at 8:32 PM
Thank you for reporting this issue. We have fixed this bug and the fix will be available in the next version of ASP.NET MVC.

Thanks,
The ASP.NET Team
Posted by Microsoft on 3/30/2011 at 4:01 AM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by Microsoft on 3/29/2011 at 11:13 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.