New to .NET - If Then Else condition against database results

  • Thread starter Thread starter Troy Stanley - CyberWarehouse.com
  • Start date Start date
T

Troy Stanley - CyberWarehouse.com

How does one evaluate if a field is null to display it in the datalist or
repeater? I have tried a number of different things...

Would anyone know how to do this?

<asp:Repeater id="customers" runat="server"><HeaderTemplate>
<table border="1" width="100%">

</HeaderTemplate><ItemTemplate>
<%IF #Container.DataItem("detProcessor") <> "" Then
<tr><td><%#Container.DataItem("detProcessor")%></td></tr>
End IF %>

</ItemTemplate><FooterTemplate>
</table>
</FooterTemplate></asp:Repeater>

I have a feeling that I can't run arguments against the container within the
repeater.


--
Thanks!

Troy Stanley
devteam a.t cyberwarehouse.com
www.CyberWarehouse.com
 
I'm reasonably new too, but I think an acceptable solution would be to
pass the databound item to a function, which would sit in your
code-behind and return your formatted data if it weren't null.

<%# FormatData(DataBinder.Eval(Container.DataItem, "detProcessor")) %>

in your repeater...

then in your code-behind...

protected string FormatData(string data)
{
string result = "No data";
if (!data.Equals(string.Empty))
result = data.ToString();
return result;
}

I think that would work...?
 
Back
Top