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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:45:39+00:00 2026-05-16T05:45:39+00:00

i am getting error after post, when i am using dropdown in my mvc

  • 0

i am getting error after post, when i am using dropdown in my mvc website, the code is as follows

ViewData["JobSite_JobCategories1"] = new SelectList(context.JobSite_JobCategories, "Id", "Category", null);

<%= Html.DropDownList("JobCategory", ((IEnumerable<SelectListItem>)ViewData["JobSite_JobCategories1"]))%>
<%= Html.ValidationMessageFor(model => model.JobCategory) %>

The validation is not working, and also after i catch error i fill the viewdata[“JobSite_JobCategories1”] with selectlist again but still, it gives error

There is no ViewData item of type ‘IEnumerable’ that has the key ‘JobCategory’.

Please can any one suggest me the solution to this problem, any articles, samples, links.

  • 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-16T05:45:40+00:00Added an answer on May 16, 2026 at 5:45 am

    Everything looks correct mostly.

    You are building the SelectList properly here:

    ViewData["JobSite_JobCategories1"] = new SelectList(context.JobSite_JobCategories, "Id", "Category", null); 
    

    I am not sure why you are not just casting it to what it is here, a SelectList:

    <%= Html.DropDownList("JobCategory", (SelectList)(ViewData["JobSite_JobCategories1"]))%>
    

    Any reason you are not using DropDownListFor to build it? Eg:

    <%= Html.DropDownList(m => m.JobCategory, (SelectList)(ViewData["JobSite_JobCategories1"]))%>
    

    Also I posted this question a while back that might be of interest for you to read:

    Best way of implementing DropDownList in ASP.NET MVC 2?

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

Sidebar

Related Questions

I keep getting this error after my code has run between 5-10 min CallbackOnCollectedDelegate
Help me please. After sending post query i have webexception Error getting response stream
Keep getting this error after inserting a subdatasheet into a query and trying to
I am getting this error after adding the libxml2.2.dylib file Linking /Users/Biranchi/Desktop/Funmovies TabBarController/build/Debug-iphonesimulator/funmovies.app/funmovies (1
We are getting this error after upgrading to NHibernate 2.1. [QueryException: Cannot simultaneously fetch
I had a class loader working although I am now getting an error after
I am getting the following error after running git svn rebase: 'update-index --refresh: command
I'm getting a getaddress error and after doing some sleuthing, it looks like it
I am getting error of System.MissingMethodException after I have an optional parameter in one
I'm getting a missing template error after I try rendering a partial from a

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.