D
David C
I am trying to use a CompareValidator to validate an entered date in my
asp.net page. The date is being formatted on display and apparently the
CompareValidator does not like that. Is there a way around this? below is
the section of GridView where the problem exists. Thanks.
David
<asp:TemplateField HeaderText="Activity Date"
SortExpression="ActivityDate" ItemStyle-Width="120">
<EditItemTemplate>
<asp:TextBox ID="txtActivityDate" runat="server"
Text='<%# Bind("ActivityDate", "{0:M/d/yyyy h:m tt}") %>'></asp:TextBox>
<asp:CompareValidator ID="valActivityDate"
runat="server" ErrorMessage="Activity Date must be a valid date"
Operator="DataTypeCheck" Type="Date"
Display="Dynamic"
ControlToValidate="txtActivityDate"></asp:CompareValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("ActivityDate", "{0:M/d/yyyy h:m tt}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
asp.net page. The date is being formatted on display and apparently the
CompareValidator does not like that. Is there a way around this? below is
the section of GridView where the problem exists. Thanks.
David
<asp:TemplateField HeaderText="Activity Date"
SortExpression="ActivityDate" ItemStyle-Width="120">
<EditItemTemplate>
<asp:TextBox ID="txtActivityDate" runat="server"
Text='<%# Bind("ActivityDate", "{0:M/d/yyyy h:m tt}") %>'></asp:TextBox>
<asp:CompareValidator ID="valActivityDate"
runat="server" ErrorMessage="Activity Date must be a valid date"
Operator="DataTypeCheck" Type="Date"
Display="Dynamic"
ControlToValidate="txtActivityDate"></asp:CompareValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("ActivityDate", "{0:M/d/yyyy h:m tt}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>