我已经内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
的格式?
感谢名单