2009-07-16 79 views
0

我有一個asp:TableCell,並希望根據條件綁定日期,如果日期是DateTime.MinValue它應該顯示空值,否則日期。條件約束日期<asp:TableCell>

我想在asp.net(3.5)C#中的解決方案。

謝謝

回答

0

如果你可以在後面的代碼中設置值,那麼這很容易。

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

如果在後面的代碼中沒有明確表示可以綁定到C#屬性或方法。 例

ASPX - 你的表格單元格<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() : ""; 
} 

這是否提供了一個指南針,讓你在正確的方向開始了嗎?