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

  • Thread starter Troy Stanley - CyberWarehouse.com
  • 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
 
B

Brandon Wagner

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...?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top