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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:47:10+00:00 2026-05-11T21:47:10+00:00

Scenario: I have a page which contains a dropdownlist and a table which contains

  • 0

Scenario:
I have a page which contains a dropdownlist and a table which contains a list of details based on the value selected in the dropdownlist when the dropdown is changed.

Now at first instance when the page is loaded, the dropdownlist contains a blank value followed by other values. So for the first time there won’t be any values in the ‘model’ object and so when rendering data, say ‘model.ID’, it will fail because ‘model’ is null.

Currently I am handling this scenario by writing this bit of code in the aspx page

if (Model != null)
{
   //DisplayData
   Model.ID
}

Is this the right way to do it or is there a more elegant way in MVC?

  • 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-11T21:47:10+00:00Added an answer on May 11, 2026 at 9:47 pm

    I would consider handing your view a new, empty model if you can, rather than null. This will save you from having to have null checks everywhere, and really, what’s a View without a model?

    If that’s not possible (your model is complex and has non-nullable fields that you don’t want to display), then consider changing the workflow of the page so that the part displaying the model (perhaps a partial view) isn’t shown until after the user makes the initial selection.

    If that’s not possible either, then really, I wouldn’t say that there is much wrong with your approach other than it’s tedious to program.

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

Sidebar

Related Questions

I have the following scenario where I have a page say parentPage.html, which contains
Scenario: I have a login page which uses ajax to validate a user and
I have the following scenario. I have a search page which is split into
I have a HTML page which contains users data and the data is stored
This is the scenario: I have a web page with a ListView lv_create_claim which
I have a custom search control on my page (asp.net) which contains a textbox
I have an aspx master/content page scenario. The parent page has an IFrame which
I have an application which tab page based. To decrease the startup time I
I have scenario, Page contains Check in date and Check out date for input.
I have an scenario where in I have a page, which have <script> tag

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.