D
doug
I have a gridview and have placed customvalidator controls in it.
If I put a break on the sub to do custom validation, run the page, select a
row and press the EDIT button, putting me into Update/Cancel mode, I can edit
the date textbox putting in garbage and press update. It takes the
breakpoint, I step thru, it sets value.isValid=False, and when I exit
routine, same sub fires again (hits same break point) and flow values same
path. Garbage date value still there. If I continue on now, it displays the
gridview, original value of date textbox is back, my error message is not
displayed, but I'm still in Update/Cancel mode,not Edit mode so the update
didn't take place.
<asp:TemplateField HeaderText="Date Stamp"
SortExpression="date_stamp">
<EditItemTemplate>
<asp:CustomValidator ID="Date_Stamp_Update_Validator"
runat="server"
ControlToValidate="Date_Stamp_Update_Txt"
OnServerValidate="Date_Stamp_Update_Txt_Validate"
ValidateEmptyText="true"
Display="Static"
SetFocusOnError="true"
ErrorMessage="Must be YYYY-MM-DD!" ></asp:CustomValidator>
<asp:TextBox ID="Date_Stamp_Update_Txt" runat="server"
Text='<%# Bind("date_stamp") %>'
BorderStyle="Ridge" BackColor="LightYellow"
MaxLength="10" Width="65px"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Date_Stamp_Label" runat="server"
Text='<%# Bind("date_stamp") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Bottom" Width="9%"
Wrap="True"/>
<HeaderStyle VerticalAlign="Bottom" />
</asp:TemplateField>
Protected Sub Date_Stamp_Update_Txt_Validate(ByVal sender As Object, ByVal
value As ServerValidateEventArgs)
' Must be YYYY-MM-DD Format:
If value.Value.ToString.Length = 10 Then
Dim dte As DateTime
If DateTime.TryParse(value.Value, dte) Then
value.IsValid = True
Else
value.IsValid = False
End If
Else
value.IsValid = False
End If
End Sub
If I put a break on the sub to do custom validation, run the page, select a
row and press the EDIT button, putting me into Update/Cancel mode, I can edit
the date textbox putting in garbage and press update. It takes the
breakpoint, I step thru, it sets value.isValid=False, and when I exit
routine, same sub fires again (hits same break point) and flow values same
path. Garbage date value still there. If I continue on now, it displays the
gridview, original value of date textbox is back, my error message is not
displayed, but I'm still in Update/Cancel mode,not Edit mode so the update
didn't take place.
<asp:TemplateField HeaderText="Date Stamp"
SortExpression="date_stamp">
<EditItemTemplate>
<asp:CustomValidator ID="Date_Stamp_Update_Validator"
runat="server"
ControlToValidate="Date_Stamp_Update_Txt"
OnServerValidate="Date_Stamp_Update_Txt_Validate"
ValidateEmptyText="true"
Display="Static"
SetFocusOnError="true"
ErrorMessage="Must be YYYY-MM-DD!" ></asp:CustomValidator>
<asp:TextBox ID="Date_Stamp_Update_Txt" runat="server"
Text='<%# Bind("date_stamp") %>'
BorderStyle="Ridge" BackColor="LightYellow"
MaxLength="10" Width="65px"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Date_Stamp_Label" runat="server"
Text='<%# Bind("date_stamp") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Bottom" Width="9%"
Wrap="True"/>
<HeaderStyle VerticalAlign="Bottom" />
</asp:TemplateField>
Protected Sub Date_Stamp_Update_Txt_Validate(ByVal sender As Object, ByVal
value As ServerValidateEventArgs)
' Must be YYYY-MM-DD Format:
If value.Value.ToString.Length = 10 Then
Dim dte As DateTime
If DateTime.TryParse(value.Value, dte) Then
value.IsValid = True
Else
value.IsValid = False
End If
Else
value.IsValid = False
End If
End Sub