views:

105

answers:

1

hi

i have a asp:TableCell and want to bind date to this on the basis of condition such that if date is DateTime.MinValue it should display empty value else the date.

i want solution in asp.net(3.5) C#.

thanks

A: 

If you can just set the value in the code behind, then it's very easy.

this.myTableCell.text = yourDate > DateTime.MinValue ? yourDate : "";

If not setable explicitly in the code behind, you could simply bind to a C# property or method. Example

ASPX - your table cell <asp:TableCell Text="<%= MyDate() %>" .../>

C# Code Behind ----  this could be a property with get / set accessors or a method
public string MyDate() 
{ 
  DateTime myDateTime = GetDateTime();
  return myDateTime > DateTime.MinValue ? myDateTime.ToString() : "";
}

Does this provide a compass to get you started in the right direction?