Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validating a calendar date in a datagrid.
Message
 
To
All
General information
Forum:
ASP.NET
Category:
WebForms
Title:
Validating a calendar date in a datagrid.
Miscellaneous
Thread ID:
00704891
Message ID:
00704891
Views:
43
Hi,

I am trying to validate a date from a calendar control that is embedded in a datagrid. When the user clicks the edit button on the grid, they choose a date for the transaction and enter an amount. I have three different validation controls validating the amount field, but I can't seem to get a range validator working for the calendar control. I have embedded the range validator in the edit template of the column template for the calendar. I keep getting an error which says the date value cannot be converted to the date data type for maximum value parameter of the range validator control.

Here is my code:
<asp:TemplateColumn HeaderText="Transfer Date">
  <ItemTemplate>
    <%# Container.DataItem("TransferDateDT") %>
  </ItemTemplate>
  <EditItemTemplate>
    <asp:Calendar ID="calTransferDate" Runat="server" Font-Size="8pt" Font- Names="Verdana" SelectedDate='<%# Container.DataItem("TransferDateDT") %>'>
    </asp:Calendar>
    <asp:RangeValidator ID="TransferDateValidator" Display="Dynamic" Runat="server" ErrorMessage="Date must be between today and 7 days in the future." ControlToValidate="calTransferDate" MinimumValue='<%# ctype(#9/26/2002#, date) %>' MaximumValue='<%# ctype(#10/03/2002#, date) %>' Type="Date" />
  </EditItemTemplate>
</asp:TemplateColumn>
Has anyone else done this? If not, does anyone know of a sample that illustrates this, I cannot seem to find one.

Thanks in advance,

Rodney Hall
Next
Reply
Map
View

Click here to load this message in the networking platform