I have added a ListView to a web form and this code works when the data columns in the bound dataset have values:
<asp:ListView ID="picturesListView" runat="server"
GroupPlaceholderID="groupsGoHere"
ItemPlaceholderID="itemsGoHere"
GroupItemCount="1" >
<LayoutTemplate>
<p id="pictureList">Picture List:</p>
<ol id="imagegallery">
<asp:PlaceHolder ID="groupsGoHere" runat="server" />
</ol>
</LayoutTemplate>
<GroupTemplate>
<asp:PlaceHolder runat="server" ID="itemsGoHere" />
</GroupTemplate>
<ItemTemplate>
<li>
<a href="<%# Eval("ImageURL")%>" title="<%#Eval("ImageDesc") %>">
<%#Eval("ImageDesc")%>
</a>
</li>
</ItemTemplate>
</asp:ListView>
Then in the codebehind file, I have just these 2 lines to populate the Listview:
picturesListView.DataSource = dsImages
picturesListView.DataBind()
All rows in the dataset have a value for the ImageURL column but the ImageDesc column can be null or an empty string. How could I check to see if ImageDesc for a given row is empty and construct a "pseudo-descriptor" such as "untitled picture no. N" where N is the relative row number in the dataset. I suppose I could change the stored procedure that returns this dataset...but this seems as if it should be possible.