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

Will you give this article a +1 ? Thanks in advance

About The Author

Suprotim Agarwal
Suprotim Agarwal, ASP.NET Architecture MVP (Microsoft Most Valuable Professional) works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He is the Editor of a Developer Magazine called DNC Magazine. He has also written two EBooks 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook

Follow him on twitter @suprotimagarwal

No comments: