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(C ontainer.D ataItem, "CITY")) and Not IsDBNull(DataBinder.Eval(C ontainer.D ataItem, "STATE"))%>'>
<asp:TableCell><%# DataBinder.Eval(Container. DataItem, "CITY") %>, <%# DataBinder.Eval(Container. DataItem, "STATE") %> <%# DataBinder.Eval(Container. DataItem, "ZIP") %></asp:TableCell></asp:Ta bleRow>
-------------------------- ---------- ---------- --------
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> < /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(C ontainer.D ataItem, "ADDRESS"))%>'>
<asp:TableCell><%# DataBinder.Eval(Container. DataItem, "ADDRESS") %></asp:TableCell></asp:Ta bleRow>
<asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(C ontainer.D ataItem, "CITY")) and Not IsDBNull(DataBinder.Eval(C ontainer.D ataItem, "STATE"))%>'>
<asp:TableCell><%# DataBinder.Eval(Container. DataItem, "CITY") %>, <%# DataBinder.Eval(Container. DataItem, "STATE") %> <%# DataBinder.Eval(Container. DataItem, "ZIP") %></asp:TableCell></asp:Ta bleRow>
<asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(C ontainer.D ataItem, "AREA_CODE")) and Not IsDBNull(DataBinder.Eval(C ontainer.D ataItem, "PHONE"))%>'>
<asp:TableCell>(<%# DataBinder.Eval(Container. DataItem, "AREA_CODE") %>) <%# DataBinder.Eval(Container. DataItem, "PHONE") %> </asp:TableCell></asp:Tabl eRow>
<asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(C ontainer.D ataItem, "AREA_CODE")) and Not IsDBNull(DataBinder.Eval(C ontainer.D ataItem, "FAX"))%>'>
<asp:TableCell><i>Fax: </i>(<%# DataBinder.Eval(Container. DataItem, "AREA_CODE") %>) <%# DataBinder.Eval(Container. DataItem, "FAX") %></asp:TableCell></asp:Ta bleRow>
<asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(C ontainer.D ataItem, "WEBSITE"))%>'>
<asp:TableCell> <a href='<%# DataBinder.Eval(Container. DataItem, "WEBSITE") %>' target=_blank>Website</a>< /asp:Table Cell></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>
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(C
<asp:TableCell><%# DataBinder.Eval(Container.
--------------------------
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><
</HeaderTemplate>
<ItemTemplate>
<tr><td width=25% valign=top>
<table><tr><td valign=top><%# DataBinder.Eval(Container,
</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(C
<asp:TableCell><%# DataBinder.Eval(Container.
<asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(C
<asp:TableCell><%# DataBinder.Eval(Container.
<asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(C
<asp:TableCell>(<%# DataBinder.Eval(Container.
<asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(C
<asp:TableCell><i>Fax: </i>(<%# DataBinder.Eval(Container.
<asp:TableRow Visible='<%# Not IsDBNull(DataBinder.Eval(C
<asp:TableCell> <a href='<%# DataBinder.Eval(Container.
<asp:TableRow>
<asp:TableCell><%# DataBinder.Eval(Container.
</asp:Table>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.