DataBinder.Eval(Container.DataItem, "date") when date might be missing

From: bg (stefan_bg_edlund_at_hotmail.com)
Date: 04/14/04


Date: Wed, 14 Apr 2004 18:19:20 +0200

Hi!

How do I check if "date" exists before using that code?

I've built a RSSreader and sometimes there's a date in it and sometimes not.
How can I check if it exists to avoid crash (DataBinder.Eval:
'System.Data.DataRowView' does not contain a property with the name date)

<asp:DataGrid
 id="RssNewsGrid"
 AutoGenerateColumns="False"
 runat="server"
 AlternatingItemStyle-BackColor="#ffffff"
 HeaderStyle-BackColor="#ffffff"
 OnPageIndexChanged="ChangePaging"
 AllowPaging="True"
 Width="100%"
 Cellpadding="4"
 BorderWidth="0">
 <PagerStyle Mode="NumericPages" Visible="False" HorizontalAlign="Right" />
  <Columns>
    <asp:TemplateColumn>
  <HeaderTemplate>
  </HeaderTemplate>
  <ItemTemplate>
   <h2 class="<%=HeaderClass2%>"><%# DataBinder.Eval(Container.DataItem,
"title") %></h2>
   <em><%# DataBinder.Eval(Container.DataItem, "date") %>
  </ItemTemplate>
    </asp:TemplateColumn>
  </Columns>
</asp:DataGrid>

Thank you
/Stefan


Loading