Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8835065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:10:27+00:00 2026-06-14T09:10:27+00:00

I have a GridView on my page that has Validation controls (require and regular

  • 0

I have a GridView on my page that has Validation controls (require and regular expression) on the input fields of the Edit template. Basically, I’m validating the user submitted inputs when they click “Edit” in a GridView.

Here’s some sample markup:

<asp:TemplateField HeaderText="Name" SortExpression="Name">
    <EditItemTemplate>
        <asp:TextBox ID="EditFacultyName" runat="server" Text='<%# Bind("Name") %>' 
            CausesValidation="True"></asp:TextBox>
        <br />
        <asp:RequiredFieldValidator ID="EditFacultyNameRequired" runat="server" 
            ControlToValidate="EditFacultyName" ErrorMessage="You must provide a name" 
            ValidationGroup="ValidateGridView" Display="Dynamic"></asp:RequiredFieldValidator>
        <asp:RegularExpressionValidator ValidationExpression="^[a-zA-Z0-9 ]*$" 
            ID="EditFacultyNameRegex" runat="server" 
            ControlToValidate="EditFacultyName" 
            ErrorMessage="Must be alphanumeric characters and spaces" Display="Dynamic" ValidationGroup="ValidateGridView"></asp:RegularExpressionValidator>
    </EditItemTemplate>
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
    </ItemTemplate>
</asp:TemplateField>

The validation controls fire when I lose focus to the input element, but they won’t stop the page from being submitted if I click “Update” in the GridView.

I’ve made a more graphic example.

enter image description here

Here you can that the Name field is empty, and the Location field contains invalid characters. The validation controls show me an error, but when I click Update (circled in red) they still go through and get added to the database.

How can I stop that from happening?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:10:28+00:00Added an answer on June 14, 2026 at 9:10 am

    You will need to check the page’s IsValid property in your update event handler in your server-side code. It’s a good practice to do this in addition to the client-side validation, because a malicious user could easily bypass client-side validation.

    protected void OnUpdate(object sender, EventArgs e)
    {
        if(Page.IsValid)
        {
            // update data store
        }
    }
    

    http://msdn.microsoft.com/en-us/library/system.web.ui.page.isvalid(v=vs.100).aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have web forms page that has 2 controls. A gridview and an associated
Basically I have a gridview that I page through the server instead of in
I have a aspx page that has a GridView with a datasource of an
I have a GridView which has following template field that holds the filename, when
I have a GridView on an ASP.NET page with a TemplateField column that has
I have a page, lets call it SourceTypes.aspx, that has a a GridView that
I have a page that includes a GridView in it. That GridView is paged
I have a GridView on a .aspx page with a hidden column which has
I have a GridView that has it's columns added dynamically in codebehind. I've added
I have a Gridview that has a timestamp as one of the rows. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.