M
Markus
I have a datagrid with Edit, Update, Cancel.
Everything without validation works fine but when the user edits the
date column I would like the regularExpressionValidator to display the
error message in the ValidationSummary when incorrect
Any help is appreciated.
<asp:datagrid
id="dgTrainingDates"
CssClass="btc_formBlackL"
Runat="server"
DataKeyField="Training_ID" OnCancelCommand="dgTrainingDates_CancelCommand"
OnUpdateCommand="dgTrainingDates_UpdateCommand"
OnEditCommand="dgTrainingDates_EditCommand"
GridLines="None"
BorderWidth="0"
BorderStyle="NotSet"
AutoGenerateColumns="False"
EnableViewState="true">
<Columns>
<asp:TemplateColumn>
<HeaderStyle CssClass="btc_formPurpleL"></HeaderStyle>
<HeaderTemplate>Training Dates</HeaderTemplate>
<ItemTemplate><%# container.dataitem("TrainingDate")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="UdateTrainingDate" CssClass="btc_formBlackL"
Runat="server" Width="90"
Columns="8"
Text='<%# container.dataItem("TrainingDate")%>'
EnableViewState="True">
</asp:TextBox>
<asp:RegularExpressionValidator
id="reg1"
CssClass="btc_loginErr"
Runat="server"
ControlToValidate="UdateTrainingDate"
Text="*"
ErrorMessage="Please enter a valid date (MM/DD/YYYY)"
display="none"
ValidationExpression="^(?:\s+)?(?=\d)(?????:0?[13578]|1[02])(\/|-|\.)31)\1|(??:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(??:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(???:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(??:16|[2468][048]|[3579][26])00))))|(??:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(??:1[6-9]|[2-9]\d)?\d{2}))($|
(?=\d)))?(((0?[1-9]|1[012])[0-5]\d){0,2}(
[AP]M))|([01]\d|2[0-3])[0-5]\d){1,2})?(?:\s+)?$">
</asp:RegularExpressionValidator>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
</Columns>
</asp:datagrid>
<asp:validationsummary id="ValidationSummary1"
runat="server"
CssClass="btc_loginErr"
EnableClientScript="true"
displaymode="List"
headertext="There are problems with the following form fields:"
showmessagebox="false"
showsummary="True"></asp:validationsummary>
Everything without validation works fine but when the user edits the
date column I would like the regularExpressionValidator to display the
error message in the ValidationSummary when incorrect
Any help is appreciated.
<asp:datagrid
id="dgTrainingDates"
CssClass="btc_formBlackL"
Runat="server"
DataKeyField="Training_ID" OnCancelCommand="dgTrainingDates_CancelCommand"
OnUpdateCommand="dgTrainingDates_UpdateCommand"
OnEditCommand="dgTrainingDates_EditCommand"
GridLines="None"
BorderWidth="0"
BorderStyle="NotSet"
AutoGenerateColumns="False"
EnableViewState="true">
<Columns>
<asp:TemplateColumn>
<HeaderStyle CssClass="btc_formPurpleL"></HeaderStyle>
<HeaderTemplate>Training Dates</HeaderTemplate>
<ItemTemplate><%# container.dataitem("TrainingDate")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="UdateTrainingDate" CssClass="btc_formBlackL"
Runat="server" Width="90"
Columns="8"
Text='<%# container.dataItem("TrainingDate")%>'
EnableViewState="True">
</asp:TextBox>
<asp:RegularExpressionValidator
id="reg1"
CssClass="btc_loginErr"
Runat="server"
ControlToValidate="UdateTrainingDate"
Text="*"
ErrorMessage="Please enter a valid date (MM/DD/YYYY)"
display="none"
ValidationExpression="^(?:\s+)?(?=\d)(?????:0?[13578]|1[02])(\/|-|\.)31)\1|(??:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(??:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(???:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(??:16|[2468][048]|[3579][26])00))))|(??:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(??:1[6-9]|[2-9]\d)?\d{2}))($|
(?=\d)))?(((0?[1-9]|1[012])[0-5]\d){0,2}(
[AP]M))|([01]\d|2[0-3])[0-5]\d){1,2})?(?:\s+)?$">
</asp:RegularExpressionValidator>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
</Columns>
</asp:datagrid>
<asp:validationsummary id="ValidationSummary1"
runat="server"
CssClass="btc_loginErr"
EnableClientScript="true"
displaymode="List"
headertext="There are problems with the following form fields:"
showmessagebox="false"
showsummary="True"></asp:validationsummary>