user3264676 user3264676 - 4 months ago 20
Javascript Question

How to get Column Value for a given Row within GridView using javascript in asp.net?

I have a GridView, I have a row index in a javascript function. Now I want to get the value of a Column for that index in a GridView using javascript.
Please tell me how can I do this?

Answer

Check this out...

 var tbl = document.getElementById('Gridview1');

 var tbl_row = tbl.rows[parseInt(RowIndex) + 1];

 var tbl_Cell = tbl_row.cells[no of the cell];

 var value= tbl_Cell.innerHTML.toString();

Here no of the cell indicates the column number.

If it is a template field,you can try this..

var value=document.getElementById('GridViewId_ColumnID_' + RowIndex).value;