Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

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

0.00/5 (No votes)
28 Dec 2011 1  
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
CSS
.selectedRow
{
color: #303030;
font-size:3em;
font-weight:bold;
}
.normalRow
{
color: #909090;
font-size:2em;
font-weight:normal;
}


Javascript
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

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here