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 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

I need to capture right mouse click event inside a iframe in asp.net using
I need to capture the amount of time that ASP.net takes to execute each
I need to capture an ASP.NET Session Tiemout in a GeneXus X application generated
I need to capture the event when my app is showing a dialog and
We have a need to capture signatures from an iOS app – the use
I need to capture when the Page_SizeChanged event fires in a WPF Browser application
I need to capture all mouse events on a .NET's WebBrowser, process them and
I have a string from which I need to capture one and possibly two
I need to capture a tab keypress event on some dynamic inputs, but the
I need to capture the event raised when a flash video ends. If possible,

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.