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 312149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:59:23+00:00 2026-05-12T07:59:23+00:00

I have a site that was using ASP.Net MVC Beta 5, and I have

  • 0

I have a site that was using ASP.Net MVC Beta 5, and I have just upgraded it to ASP.Net MVC 1.0. I am having trouble with the selected item in a drop down list.

The follow person has a similar question (Html.DropDownList in ASP.NET MVC RC (refresh) not pre-selecting item) but I there is no answer (other than it might be a bug)

My Controller method looks as follows:

[AcceptVerbs(HttpVerbs.Get)]
public ActionResult View(Guid id)
{
    IntegrationLogic logic = new IntegrationLogic(new IntegrationLinq());
    CompanyLogic companyLogic = new CompanyLogic(new CompanyLinq());
    IntegrationContainer container = new IntegrationContainer();

    container.Sources = logic.GetImportSource(id);
    container.Companies = companyLogic.GetCompanies(); // Returns a IList<company>
    container.SourceActions = logic.GetAllSourceActions(); // Returns an IList<SourceAction>
    container.SinkActions = logic.GetAllSinkActions();
    container.SuccessActions = logic.GetAllSuccessActions();
    container.FailureActions = logic.GetAllFailureActions();
    container.Actions = logic.GetAllActions();
    container.Watchers = logic.GetAllWatcherActions();
    container.ChainActions = logic.GetAllChainActions();

    return View("View", container);
 }

The view is a strongly typed against the Model as follows

public partial class View : ViewPage<IntegrationContainer> {}

The problem area in the view template is :

  <label for="Companies">Company: </label><%=Html.DropDownList("Companies",
                                                new SelectList(ViewData.Model.Companies, "id", "name", item.CompanyID))%>

I am creating a Dropdown List, the selected item never actually gets selected – and that is the problem. “item.CompanyID” is a Guid, “id” is a Guid and “name” is a string on the company object supplied in the IList that is held in the ViewData.Model.Companies instance.

Is this actually a bug ?- I find it hard to understand why this is still present in ASP.Net MVC… I would be totally happy if it is something I have done.

Regardless, what would be the suggested work around?

Thanks

  • 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-12T07:59:23+00:00Added an answer on May 12, 2026 at 7:59 am

    It turns out that if the name of your control via Html.DropDownList is the same name as the collection object it causes an issue with ASP.Net MVC.

    So if I change the following code:

    <label for="Companies">Company: </label><%=Html.DropDownList("Companies",
                                                    new SelectList(ViewData.Model.Companies, "id", "name", item.CompanyID))%>
    

    to:

    <label for="Companies">Company: </label><%=Html.DropDownList("company",
                                                    new SelectList(ViewData.Model.Companies, "id", "name", item.CompanyID))%>
    

    all now works. This is because the name of collection on the model was Model.Companies…. bonkers… also note, that changing the case of the name of the control from “Companies” to “companies” does not work either (which makes sense I suppose).

    I could change the Model, but as most of it is built using Linq-to-SQL I think it is easier to change the names of the Html elements.

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

Sidebar

Related Questions

I have an ASP.NET MVC (Beta 1) website that I'm using themes with. When
I have a site that was built using asp.net MVC version 1. I recently
I have an ASP.NET MVC site that it's in two languages using Resources. To
I have a site that I am currently working on in ASP.NET 2.0 using
I'm just starting to get into ASP.NET MVC, and saw today that the Beta
On an ASP.NET MVC (Beta) site that I am developing sometimes calls to ActionLink
I have put together a small ASP.NET MVC 2 site that does some very
I have an ASP.Net MVC site that has a subdomain for each customer e.g.
We have an ASP.Net MVC site that needs to authenticate to facebook to post
I have an ASP.NET MVC 3 site using a custom route for specifying the

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.