ASP.net change GridView cell color on mouseout

Murray Brown
Murray Brown used Ask the Experts™
on
In my ASP.net GridView I previously used the following code to make cells clickable.
How can I use similar code to  change the cells color on mouseout

    Private Sub GridView1_RowCreated(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowCreated


        If e.Row.RowType = DataControlRowType.DataRow Then
            'Following link shows how cells are made clickable
            '//https://stackoverflow.com/questions/31202877/get-clicked-cell-index-in-gridview-not-datagridview-asp-net
            For i As Integer = 0 To e.Row.Cells.Count - 1
                Dim cell As TableCell = e.Row.Cells(i)
                cell.Attributes("onmouseover") = "this.style.cursor='pointer';this.style.textDecoration='underline';"
                cell.Attributes("onmouseout") = "this.style.textDecoration='none';"
                'cell.ToolTip = "You can click this cell"
                cell.Attributes("onclick") = String.Format("document.getElementById('{0}').value = {1}; {2}", SelectedGridCellIndex.ClientID, i, Page.ClientScript.GetPostBackClientHyperlink(CType(sender, GridView), String.Format("Select${0}", e.Row.RowIndex)))
            Next
        End If


    End Sub

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Developer User Interface
Commented:
cell.Attributes("onmouseover") = "this.style.cursor='pointer';this.style.textDecoration='underline';this.style.background='red';"
cell.Attributes("onmouseout") = "this.style.textDecoration='none';this.style.background=''"

Open in new window

Murray BrownASP.net/VSTO Developer

Author

Commented:
Great. Thanks very much

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial