Link to home
Start Free TrialLog in
Avatar of Leprechaun
Leprechaun

asked on

Dynamically excluding a row in a data repeater when there's bad data

I have a repeater that doesn't display some info if null is returned in the recordset.  For example, if either the state or city names are  null then that line of the address is omitted.

This works fine, but every now and again I have some bad data.  The word "null" appears as a value in some cases, so I want to not only exclude null values but also "null" literals.

How would I modify the following to accomplish this?
------------------------------------------------------
<asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(Container.DataItem, "CITY")) and Not IsDBNull(DataBinder.Eval(Container.DataItem, "STATE"))%>'>
<asp:TableCell><%# DataBinder.Eval(Container.DataItem, "CITY") %>, <%# DataBinder.Eval(Container.DataItem, "STATE") %> &nbsp;<%# DataBinder.Eval(Container.DataItem, "ZIP") %></asp:TableCell></asp:TableRow>
------------------------------------------------------

The whole code for the repeater is below

Thanks.

Leprechaun

---------------------
<asp:repeater id=Repeater1 runat="server">
<HeaderTemplate>
      <tr><td width=25%><B>Store Name:</B></td><td width=75%><b>Address:</b></td></tr>
</HeaderTemplate>
<ItemTemplate>
      <tr><td width=25% valign=top>
      <table><tr><td valign=top><%# DataBinder.Eval(Container, "ItemIndex") +  1 %>.<br>&nbsp;&nbsp;&nbsp;</td><td valign=top><%# DataBinder.Eval(Container.DataItem, "COMPANY_NAME").ToUpper() %></td></tr></table>
      </td>
      <td width=75% valign=top>
      <asp:table runat="server" ID="Table1" NAME="Table1" BorderWidth=0 CellPadding=0 CellSpacing=0>
            <asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(Container.DataItem, "ADDRESS"))%>'>
                  <asp:TableCell><%# DataBinder.Eval(Container.DataItem, "ADDRESS") %></asp:TableCell></asp:TableRow>
            <asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(Container.DataItem, "CITY")) and Not IsDBNull(DataBinder.Eval(Container.DataItem, "STATE"))%>'>
                  <asp:TableCell><%# DataBinder.Eval(Container.DataItem, "CITY") %>, <%# DataBinder.Eval(Container.DataItem, "STATE") %> &nbsp;<%# DataBinder.Eval(Container.DataItem, "ZIP") %></asp:TableCell></asp:TableRow>      
            <asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(Container.DataItem, "AREA_CODE")) and Not IsDBNull(DataBinder.Eval(Container.DataItem, "PHONE"))%>'>
                  <asp:TableCell>(<%# DataBinder.Eval(Container.DataItem, "AREA_CODE") %>) <%# DataBinder.Eval(Container.DataItem, "PHONE") %> </asp:TableCell></asp:TableRow>
            <asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(Container.DataItem, "AREA_CODE")) and Not IsDBNull(DataBinder.Eval(Container.DataItem, "FAX"))%>'>
                  <asp:TableCell><i>Fax: </i>(<%# DataBinder.Eval(Container.DataItem, "AREA_CODE") %>) <%# DataBinder.Eval(Container.DataItem, "FAX") %></asp:TableCell></asp:TableRow>
            <asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(Container.DataItem, "WEBSITE"))%>'>
                  <asp:TableCell> <a href='<%# DataBinder.Eval(Container.DataItem, "WEBSITE") %>' target=_blank>Website</a></asp:TableCell></asp:TableRow>
            <asp:TableRow>
                  <asp:TableCell><%# DataBinder.Eval(Container.DataItem, "MILES") %> miles</asp:TableCell></asp:TableRow>
      </asp:Table>
      </td>
      </tr>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
ASKER CERTIFIED SOLUTION
Avatar of jnhorst
jnhorst

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial