Friday, 15 June 2012

Highlight selected row when onclick javascript


C#
    e.Row.Attributes.Add("onclick""onGridViewRowClick(this);");   


Javascript:

       // highlight selected row javascript
        function onGridViewRowClick(row) {
            var table = document.getElementById("grid");
            for (var i = 1; i < table.rows.length - 1; i++) {
                if (i % 2 != 1) {
                    table.rows[i].className = 'gvRowStyle';
                }
                else {
                    table.rows[i].className = 'gvAlternatingRowStyle';
                }
            }
           // highlight selected row
            row.className = 'gvonclickstyle';
        }


No comments:

Post a Comment