Click/select Row in ASP.NET GridView or HTML Table






4.20/5 (5 votes)
Following are optimized code for SelectRow functionStylesheet.selectedRow{color: #303030;font-size:3em;font-weight:bold;}.normalRow{color: #909090;font-size:2em;font-weight:normal;}Javascriptfunction SelectRow(row) { // get all data rows - siblings to...
Following are optimized code for SelectRow function
Stylesheet
.selectedRow
{
color: #303030;
font-size:3em;
font-weight:bold;
}
.normalRow
{
color: #909090;
font-size:2em;
font-weight:normal;
}
Javascript
function SelectRow(row) {
// get all data rows - siblings to current
var _rows = row.parentNode.childNodes;
// deselect all data rows
try {
for (i = 0; i < _rows.length; i++) {
_rows[i].getElementsByTagName("td")[0].className='normalRow';
}
}
catch (e) { }
// select current row (formatting applied to first cell)
row.getElementsByTagName("td")[0].className='selectedRow';
}
Thanks,
Imdadhusen