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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:33:55+00:00 2026-06-09T11:33:55+00:00

I got an exception when user submitted a form without selecting any value in

  • 0

I got an exception when user submitted a form without selecting any value in the dropdownlistfor as follows:

    <div class="editor-field">
        @Html.DropDownListFor(
            x => x.TypeID,
            new SelectList(ViewBag.EventType, "ID", "Name"),
            "-- Select Event Type --"
            )
        @Html.ValidationMessageFor(model => model.TypeID)
    </div>

I got an exception:

Value cannot be null. Parameter name: items

I think I have to check if user selected a value or make an alert, but I’m not sure how to make it.

  • 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-09T11:33:56+00:00Added an answer on June 9, 2026 at 11:33 am

    You should use a nullable type for the TypeID property on your view model if you want to handle the non-selected case in your drop down list ("-- Select Event Type --"):

    public int? TypeID { get; set; }
    

    You are getting the exception because if the user doesn’t select any option in the dropdown, the default one is used:

    <option value="">"-- Select Event Type --"</option>
    

    Notice how the value is empty string. This obviously cannot be bound to a non-nullable integer type on your model.

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

Sidebar

Related Questions

ive got this exception. My Object looks like this: @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class ObjectDTO
In my Google App Engine project I got an unexpected exception: com.google.gwt.user.server.rpc.UnexpectedException: Service method
Has anyone got any experience with the following exception when using GAE urlfetch? DownloadError:
I got a OneToMany relation between User and Group Group.java @Entity public class Group
I got exception when I try to publish action to facebook. Exception : {error:{message:(#3502)
I've got exception about convert NULL to Int32. I've got a table from database
I am using following datatype in my database . but I got exception as
I got this exception ... EntityCategoryProxy could not be converted to int in ...
I am using Hibernate and got the exception ArrayIndexOutOfBoundsException. What are the possible causes?
When i run the command below: 127.0.0.1:8080/solr/suggest?spellcheck.build=true I got an exception as below, anyone

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.