……………………………………………….Expertise in .NET Technologies

  • Categories

  • Advertisements

Highlight GridView row on mouse over

Posted by Ravi Varma Thumati on May 12, 2009

Add handler for RowCreated/RowDataBound event for the grid and in this event add the attributes for onmouseover and onmouseout javascript events.

Code :

   If e.Row.RowType = DataControlRowType.DataRow Then

            Dim gv As GridView = CType(sender, GridView)

            Dim className As String = Microsoft.VisualBasic.IIf((e.Row.RowState = DataControlRowState.Alternate), gv.AlternatingRowStyle.CssClass, gv.RowStyle.CssClass)

            e.Row.Attributes.Add(“onmouseover”, “this.className=’datagrid_hovcol’;”)

            e.Row.Attributes.Add(“onmouseout”, “this.className='” + className + “‘;”)

        End If

In this code “onmouseover” specify classname directly. And in “onmouseout” find dynamically which class is specify for Normal /Alternative Row.

And also this code for highlight row.But if you want to highlight particular cell of row then change

 e.Row.Cells(1).Attributes.Add(“onmouseover”, “this.className=’datagrid_hovcol’;”)

  e.Row.Cells(1).Attributes.Add(“onmouseout”, “this.className='” + className + “‘;”)



One Response to “Highlight GridView row on mouse over”

  1. hey all, I was simply checkin’ out this weblog and I actually admire the idea of the article, and have nothing to do, so if anybody would like to to have an engrossing convo about it, please contact me on AIM, my title is heather smith

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: