2010-06-03 33 views
1

我已經內DetailsView控件定義以下模板(DetailsView控件綁定到對象數據源):我需要CompareValidator控件接受格式月/日日/年

<EditItemTemplate> 
     <asp:TextBox ID="txtReleaseDate" runat="server" 
       Text='<%# Bind("ReleaseDate", "{0:d}") %>'> 
     </asp:TextBox> 
     <asp:CompareValidator ID="valReleaseDateType" runat="server" 
       ControlToValidate="txtReleaseDate" Type="Date" Operator="DataTypeCheck" 
       Display="Dynamic" > * 
     </asp:CompareValidator> 
    </EditItemTemplate> 

假設我進入文本框txtReleaseDate格式爲month/day/year的日期,然後點擊更新插入按鈕,CompareValidator控件抱怨日期格式無效。但是如果我輸入的格式爲day/month/year,那麼對象數據源會拋出異常Cannot convert value of parameter 'releaseDate' from 'System.String' to 'System.DateTime',而CompareValidator不會抱怨。

我需要兩個控件接受相同的日期格式,所以:

a)由於我的數據庫存儲格式day/month/year日期,最好的辦法是ODS也接受以此爲有效的日期格式。可以這樣配置ODS嗎?

b)Can CompareValidator要配置爲還接受month/day/year的格式?

感謝名單

回答

1

也許你可以設置線程爲en-GB格式的CurrentUICulture。

0

嘗試設置在web.config全球化

我覺得 格式爲 「DD/MM/YYYY」

嘗試把 「EB-US」 之一。 喬運氣。

相關問題