This statement is not working, i want to show default image if there is no image uploaded pls help
@if (latestrow.thumb == null)
{
<img src="~/Images/no-pic.gif"/>
}
else
{
<img src="@latestrow.thumb"/>
}
There isn’t anything wrong with your code. Assuming latestrow.thumb is null, you’d receive the no-pic.gif.
My only guess is that latestrow.thumb has some value other than null. Perhaps using this would be a better approach assuming the value of thumb could be blank or null (and assuming it is a string):
If this doesn’t work, check the model being sent to the view and see what’s in that property. Chances are it’s populated with some value, even perhaps a blank space.
Good luck.