Results 1 to 2 of 2

Thread: Help - Validators

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Location
    Coming to a keyboard near you.
    Posts
    79

    Question Help - Validators

    I created a Datagrid and add some validators to the the edit template. Now when one validator fires and then you pres the UPDATE link for the datagrid, all the validators error out even if the data is correct. This prevents the record from being updated. What did I do wrong??

    Here is the aspx code. Did not post the code behind, it never reaches the code behind file in debug mode.

    VB Code:
    1. <%@ Page Language="vb" AutoEventWireup="false" Codebehind="ne.locations.aspx.vb" Inherits="NewsandEvents.oleDataEdit" %>
    2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    3. <HTML>
    4.     <HEAD>
    5.         <title>Walbash Technologies Locations</title>
    6.         <meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
    7.         <meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
    8.         <meta content="JavaScript" name="vs_defaultClientScript">
    9.         <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    10.     </HEAD>
    11.     <body>
    12.         <form id="Form1" method="post" runat="server">
    13.             <h2>Walbash Technologies Locations</h2>
    14.             <hr SIZE="1">
    15.             <asp:datagrid id="DataGrid1" runat="server" GridLines="Vertical" DataKeyField="City" AllowPaging="True"
    16.                 PageSize="6" BackColor="White" CellPadding="3" width="80%" BorderStyle="None" BorderWidth="1px"
    17.                 BorderColor="#999999" AutoGenerateColumns="False">
    18.                 <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#008A8C"></SelectedItemStyle>
    19.                 <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
    20.                 <ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>
    21.                 <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#000084"></HeaderStyle>
    22.                 <FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
    23.                 <Columns>
    24.                     <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
    25.                     <asp:TemplateColumn HeaderText="City">
    26.                         <ItemTemplate>
    27.                             <asp:Label id=lblCity runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.City") %>'>
    28.                             </asp:Label>
    29.                         </ItemTemplate>
    30.                         <EditItemTemplate>
    31.                             <asp:TextBox id=txtEditCity runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.City") %>'>
    32.                             </asp:TextBox><BR>
    33.                             <asp:RegularExpressionValidator id="regValCity" runat="server" ErrorMessage="AlphaNumeric Characters only." ControlToValidate="txtEditCity"
    34.                                 ValidationExpression="[\w][\t]"></asp:RegularExpressionValidator>
    35.                         </EditItemTemplate>
    36.                     </asp:TemplateColumn>
    37.                     <asp:TemplateColumn HeaderText="State/Country">
    38.                         <ItemTemplate>
    39.                             <asp:Label id=lblState runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.State/Country") %>'>
    40.                             </asp:Label>
    41.                         </ItemTemplate>
    42.                         <EditItemTemplate>
    43.                             <asp:TextBox id=txtEditState runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.State/Country") %>'>
    44.                             </asp:TextBox><BR>
    45.                             <asp:RegularExpressionValidator id="regValState" runat="server" ErrorMessage="AlaphaNumeric Characters only." ControlToValidate="txtEditState"
    46.                                 ValidationExpression="[\w][\t]"></asp:RegularExpressionValidator>
    47.                         </EditItemTemplate>
    48.                     </asp:TemplateColumn>
    49.                     <asp:TemplateColumn HeaderText="Contact Email">
    50.                         <ItemTemplate>
    51.                             <asp:Label id=lblEmail runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Contact Email") %>'>
    52.                             </asp:Label>
    53.                         </ItemTemplate>
    54.                         <EditItemTemplate>
    55.                             <asp:TextBox id=txtEditEmail runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Contact Email") %>'>
    56.                             </asp:TextBox><BR>
    57.                             <asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ErrorMessage="Invalid Email address."
    58.                                 ControlToValidate="txtEditEmail" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)[ \t]*"></asp:RegularExpressionValidator>
    59.                         </EditItemTemplate>
    60.                     </asp:TemplateColumn>
    61.                     <asp:TemplateColumn HeaderText="Active?">
    62.                         <ItemTemplate>
    63.                             <asp:Label id=lbleditactive runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Active?") %>'>
    64.                             </asp:Label>
    65.                         </ItemTemplate>
    66.                         <EditItemTemplate>
    67.                             <asp:DropDownList id=edit_active runat="server" SelectedIndex="<%# GetSelectedValue()%>">
    68.                                 <asp:ListItem value="0">Yes</asp:ListItem>
    69.                                 <asp:ListItem value="1">No</asp:ListItem>
    70.                             </asp:DropDownList>
    71.                         </EditItemTemplate>
    72.                     </asp:TemplateColumn>
    73.                     <asp:BoundColumn Visible="False" DataField="LocID"></asp:BoundColumn>
    74.                 </Columns>
    75.                 <PagerStyle Font-Size="Smaller" HorizontalAlign="Center" ForeColor="Black" BackColor="#999999"
    76.                     Mode="NumericPages"></PagerStyle>
    77.             </asp:datagrid><br>
    78.             <asp:linkbutton id="LinkButton1" runat="server" Text="Add new item" Font-Size="smaller"></asp:linkbutton><br>
    79.             <br>
    80.             <asp:label id="lblMessage" runat="server" width="80%" ForeColor="red" EnableViewState="True"></asp:label><br>
    81.         </form>
    82.     </body>
    83. </HTML>
    Last edited by Tenebrosity; Apr 3rd, 2005 at 12:47 PM. Reason: More details
    Tenebrosity
    "But the plans were on display ..."
    "On display? I eventually had to go down to the cellar to find them, With a torch."
    "That's the display department. The lights had probably gone out."
    "So had the stairs."
    "But look, you found the notice didn't you?"
    "Yes," said Arthur, "yes I did. It was on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying Beware of the Leopard."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width