At the moment your logic seems reversed.  If the value is NOT NULL you are
rendering an   and you are are attempting to fill the label when the
Item is null.

I've personally never been a fan of embedding script in HTML because it is
hard to read.  I'd do this in code-behind, in the ItemDataBound event
handler.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwebuiwebcontrolsdatalistclassitemdataboundtopic.asp

HTH,

Dean Fiala
-----------------------------
Very Practical Software, Inc.
http://www.vpsw.com/links.aspx





-----Original Message-----
From: Jeffrey Idea [mailto:[EMAIL PROTECTED]
Sent: Monday, May 10, 2004 10:16 PM
To: [EMAIL PROTECTED]
Subject: [AspNetAnyQuestionIsOk] Code to check Null values


Hi. I used the following code.  Its a label inside a table inside the
item template of a DataList.  Im trying to check for null values in
the field. What's wrong with my code? Sorry, Im new to ASP and am
still quite confused on how to properly use the <%# %> tags. :(

<TD style="VERTICAL-ALIGN: baseline; WIDTH: 20px; TEXT-ALIGN: center">
<%#If Not DataBinder.Eval(Container.DataItem,"load_optn_c") Is Null
Then %>
      &nbsp;
<%#Else%>
      <asp:Label id="lblOC" runat="server" Font-Names="Arial" Font-
Size="XX-Small" text='<%# DataBinder.Eval
(Container.DataItem,"load_optn_c")%>' Width="20px">
      </asp:Label>
<%#End If%>
</TD>

Jeff





Yahoo! Groups Links









 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
     [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 

Reply via email to