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

  • Home
  • SEARCH
  • 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 740213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:29:22+00:00 2026-05-14T08:29:22+00:00

I need to capture the ‘Update’ click event with jQuery in an asp.net GridView

  • 0

I need to capture the ‘Update’ click event with jQuery in an asp.net GridView and have no way of knowing where to start. I’m still rather new to jQuery. My GridView is attached to a SQLDataSource and, naturally, has all the bells and whistles that that combination affords. Any help would be greatly appreciated.

  • 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-05-14T08:29:23+00:00Added an answer on May 14, 2026 at 8:29 am

    Simply add the script block anywhere after the GridView is declared and it should work with the default non-templated GridView column. No code in the codebehind as it is purely a Javascript solution.

    Use this if you are using a Link-type GridView column:

    <script type="text/javascript">
        // a:contains(The text of the link here)
        $('#<%= theGridViewID.ClientID %> a:contains(Update)').click(function () {
            alert('Update click event captured from the link!');
            // return false: stop the postback from happening
            // return true or don't return anything: continue with the postback
        });
    </script>
    

    Use this if you are using a Button-type GridView column and you don’t want your Javascript to block the postback:

    <script type="text/javascript">
        // :button[value=The text of the button here]
        $('#<%= theGridViewID.ClientID %> :button[value=Update]').click(function () {
            alert('Update click event captured from the button!');
        });
    </script>
    

    Use this if you are using a Button-type GridView column and you want to have control whether to continue with the postback or not:

    <script type="text/javascript">
        // :button[value=The text of the button here]
        var updateButtons = $('#<%= theGridViewID.ClientID %> :button[value=Update]');
        updateButtons
            .attr('onclick', null)
            .click(function () {
                alert('Update click event captured from the button!');
                var doPostBack = true; // decide whether to do postback or not
                if (doPostBack) {
                    var index = updateButtons.index($(this));
                    // 'Update$' refers to the GridView command name + dollar sign
                    __doPostBack('<%= theGridViewID.UniqueID %>', 'Update$' + index);
                }
            });
    </script>
    

    Update: I think this would be a better solution in replacement of the last (3rd) script block I presented above, since you won’t need to update the __doPostBack function call manually based on the command name, and as such, it should be less error-prone:

    <script type="text/javascript">
        // :button[value=The text of the button here]
        var updateButtons = $('#<%= theGridViewID.ClientID %> :button[value=Update]');
        updateButtons.each(function () {
            var onclick = $(this).attr('onclick');
            $(this).attr('onclick', null).click(function () {
                alert('Update click event captured from the button!');
                var doPostBack = true; // decide whether to do postback or not
                if (doPostBack) {
                    onclick();
                }
            });
        });
    </script>
    

    Credit to Aristos for this idea. 🙂

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

Sidebar

Related Questions

We need to capture live video and display easily on Linux. We need a
I need to capture the HTML and do some post processing on the HTML
I need to capture a web site and am looking for an appropriate library
I need to capture the input stream from a microphone in my application, which
I am developping in C#. I need to capture a password written inside a
I am having an page. I need to capture the exception which is thrown
Need a way to allow sorting except for last item with in a list.
I need to capture the output and error of a command in my bash
I need to capture an image from a webcam (tethered camera, etc.) into a
I'm an absolute beginner with ASP.NET MVC and I'm trying to build a pretty

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.