views:

295

answers:

1

I've got a textbox in an ItemTemplate inside of a standard ASP.NET GridView. The textbox (from DevExpress) supports a client-side event 'LostFocus'. From the LostFocus event handler, I'd like to retrieve the value of that textbox as well as the value of several other fields in that row of the grid, so that I can update one of those other fields with a calculated result. Does anyone know how I can identify the row in the client-side handler so that I can parse out the values from that row without going to the server? Preferably using jquery so that I don't have to have different javascript for each browser.

A: 

If you are sure that there are no <tr> elements between the textbox and the GridView's row then you could try this:

var row = $(textbox).parents('tr:first');

Assuming that you have textbox var that represents the DOM element of the unfocused textbox.

Notice that this way the row will point to a jQuery object.

If you want the DOM element then add .get(0) in the end of the expression...

Michael Kessler
This doesn't get exactly what I want, the ':first' gives me the very first row. But after experimenting, I've decided that it may be easier to do what I want with an html table rather than have the GridView-generated html table.
bobuva
That's for sure. Just use the Repeater and generate what ever table you want in less time and less HTML code...
Michael Kessler