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?