How to quickly add a Key Up Event to all TextBoxes in an ASP.NET GridView or Table control

The quickest way to add the KeyUp event to all textboxes in a HTML Table or ASP.NET GridView control is to use jQuery. Here's how

<head runat="server">


<script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script>

<script type="text/javascript">

$(document).ready(function() {

$("#GridView1 tr :text").keyup(function() {






Here we are assuming that the table has an Id like this <table id="GridView1"> Also remember that the ASP.NET GridView renders as a table

If you haven't downloaded the latest version of jQuery yet, here are some links:

Latest jQuery and jQuery UI Theme links on Google CDN

About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal.

No comments: