views:

345

answers:

1

Still learning asp.net and mvc, please be gentle :)

Currently setting up an MVC view to consume and display an RSS feed, using this method described on CodeProject.

What I want to do is when no items are returned for the RSS feed, display a custom piece of text, eg something like the following piece of psuedocode.

If ViewData.Model.Items is not empty
 Then run the for loop
 Else display "sorry, no items to display"
End If

I know how to do this from my classic ASP days if I was displaying records from a table, being:

If tablename.EOF And tablename.BOF Then...

But I don't have the first clue as to how this is acheived in .net, particually when the results are rendered using a for loop.

If you can point me in the right direction of where I should be looking it would be greatly appreciated.

+4  A: 

I usually do something stupidly simple like this

<%
if(Model.Items.Count >0){
   foreach(..)
}
else{
%>
    Sorry, no items to display
<%
}
%>

I guess the proper way would also be to put this in a html helper extension, but above works for me

Johan Wikström
If it works, I won't knock it, and it makes perfect sense - thanks muchly.
thewinchester