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

  • Home
  • SEARCH
  • 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 7728401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:42:28+00:00 2026-06-01T05:42:28+00:00

i am getting a problem while populating data inside the dropdown… I guess since

  • 0

i am getting a problem while populating data inside the dropdown…
I guess since i am using a partial view that is why it is creating problem.
Here’s my code:

public ActionResult Register()
{
    var course = from Course c in Enum.GetValues(typeof(Course))
                     select new { ID = c, Name = c.ToString() };
     ViewData["course"] = new SelectList(course, "ID", "Name");
     return view();
}

 public enum Course
{
    [Display(Name = "Basic Level", ShortName = "Basic")]
    Basic = 1,

    [Display(Name = "Intermidiate Level")]
    Intermidiate = 2,

    [Display(Name = "Advance Level")]
    Advance = 3
}

This is my Main view:

<table style="margin-top: 10px">
<tr>
    <td valign="top">
        @{Html.RenderPartial("LogOnPartial");}
    </td>
    <td width="20px">
    </td>
    <td align="left">
        @{Html.RenderPartial("CreatePartial");}
    </td>
</tr>

I have written this in my partial view(CreatePartial):

<td>
       @Html.DropDownList("course");
</td>

Please help me

  • 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-06-01T05:42:29+00:00Added an answer on June 1, 2026 at 5:42 am

    This should work. I am unable to reproduce the problem.

    Model:

    public enum Course
    {
        [Display(Name = "Basic Level", ShortName = "Basic")]
        Basic = 1,
    
        [Display(Name = "Intermidiate Level")]
        Intermidiate = 2,
    
        [Display(Name = "Advance Level")]
        Advance = 3
    }
    

    Controller:

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            var course = from Course c in Enum.GetValues(typeof(Course))
                         select new { ID = c, Name = c.ToString() };
            ViewData["course"] = new SelectList(course, "ID", "Name");
            return View();
        }
    }
    

    Index.cshtml view:

    @{Html.RenderPartial("CreatePartial");}
    

    CreatePartial.cshtml partial:

    @Html.DropDownList("course")
    

    I suspect that this is not working after you submit the form, not when it is initially loaded. And this might happen because you probably forgot to repopulate the ViewData["course"] in your [HttpPost] action and yet tried to redisplay the same view. If you want to redisplay the same view make sure that you fill the ViewData["course"] the same way you did in your GET action that was used to initially render the page.

    Another thing to watch out is that you don’t have some other ViewData["course"] value that is conflicting.

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

Sidebar

Related Questions

I am getting a weird problem while using scanf() to store data into a
I am getting problem while setting up Session cookie using jersey. is there any
I have problem getting the dropdown menu to work using Twitter's Bootstrap. Here's my
Have problem while getting data from Memcached on .NET MVC solution. I have this
hi we are using the Delphi 5 version. We are getting problem while opening
I am getting a problem while fetching data. Its giving CFHTTPMessageGetResponseStatusCode(response) as 302 .
I am getting some problem while executing binary executable file using Java code. My
I have a problem while I need to send data using uploadify script. For
I'm facing a typical problem while am getting the Unique list using XSLT 1.0.
I am getting problem while using fwrite in php. the following code works in

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.