Sorry I am new to Dictionaries and passing them down to the view
I have all the data needed to be sent down to View.
Inside the ViewModel, this is the Dictionary setup
public virtual Dictionary<int?, ImageListItemDto> ImageDictionary { get; set; }
Within the view, I am looking to see if the certain key,value pair exists.
@if (Model != null & Model.ImageDictionary != null && !String.IsNullOrEmpty(Model.ImageDictionary[0].ImageDetail))
{
<div>@Model.ImageDictionary[0].ImageDetail</div>
}
else
{
<div>ImageDetails are not there</div>
}
I do not want to do within a for loop to display each 'ImageDetail'. This works fine if an index of 0 is there, otherwise I receive an error that 'The given key was not present in the dictionary.'
If the key does not exist, should it not go through to the else?
Thanks