How can I do this

B

Bruno Alexandre

Hi guys,

How can I perform a check if a binded field is Empty or Null, like this:
<asp:TemplateField HeaderText="Birthdate" SortExpression="bdC">
<ItemTemplate>
<% If Not String.IsNullOrEmpty(Eval("bdC")) Then%>
<%#(FormatDateTime(Eval("bdC"), DateFormat.ShortDate))%>
<% Else%>
<% end if %>
</ItemTemplate>
</asp:TemplateField>

if I try the above code, I get this error:

"Databinding methods such as Eval(), XPath(), and Bind() can only be used in
the context of a databound control."


Thank you
 
C

Cowboy \(Gregory A. Beamer\)

Try using the data bound event and testing in code behind. You can grab the
value and format as you wish.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
 

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

Top