This is a discussion on How to add mouseover function to Gridview..? within the C# Programming forums, part of the Software Development category; Content: How to add mouseover function to Gridview( To change the color of the row while mouse over in gridview)...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi friend, Here is the answer.. <asp:GridView ID="employeeGridView" OnRowCreated="MyGridView_RowCreated"> protected void MyGridView_RowCreated(object sender, GridViewRowEventArgs e) { string onmouseoverStyle = "this.style.backgroundColor='#dcdcdc'"; string onmouseoutStyle = "this.style.backgroundColor='@BackColor'"; string rowBackColor = String.Empty; if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowState == DataControlRowState.Alternate) rowBackColor = System.Drawing.ColorTranslator.ToHtml(employeeGrid View.AlternatingRowStyle.BackColor).ToString(); else rowBackColor = System.Drawing.ColorTranslator.ToHtml(employeeGrid View.RowStyle.BackColor).ToString(); e.Row.Attributes.Add("onmouseover", onmouseoverStyle); e.Row.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor)); } } |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Exporting GridView to Excel | shaalini | ASP and ASP.NET Programming | 4 | 03-26-2008 02:23 AM |
| GridView.DataBind not working | rrrajesh84in | ASP and ASP.NET Programming | 1 | 03-21-2008 10:01 PM |
| Which is the best among DataList,Repeater and GridView and Why? | poornima | ASP and ASP.NET Programming | 2 | 03-14-2008 08:44 PM |
| GridView Item Tempalte Problem | shaalini | C# Programming | 0 | 01-29-2008 09:11 PM |
| Diff inline function and ordinary function | vigneshgets | C and C++ Programming | 1 | 05-24-2007 11:34 AM |