"If" statement in repeater

P

Peter Kirk

Hi

I have a textbox generated in a "repeater". The repeater is looping over an
array of Port objects, and displaying various of its attributes. One
attribute is a DateTime object which I want displayed in the textbox. But
how do I present an empty string in the textbox if the DateTime is MinValue?
How do I check the value while the repeater is iterating?

<asp:TextBox id="DateTextBox" runat="Server" Text="<%#
((IPort)Container.DataItem).ArrivalDate %>">
</asp:TextBox>

I don't want it to display the MinValue, I want it to display an empty
string.

Thanks,
Peter
 
P

Phillip Williams

Hi Peter,

You can write a public or protected function that returns a string in the
codebehind and refer to it:
<asp:TextBox id="DateTextBox" runat="Server" Text="<%#
MyFunction(((IPort)Container.DataItem).ArrivalDate) %>">
</asp:TextBox>
 

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

No members online now.

Forum statistics

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

Latest Threads

Top