asp:datagrid style on mouseover mouseout

G

Guest

Hi

I am trying to add mouseover property to asp:datagrid in the asp .net page
My pag
So the output in HTML for a row should look like

<tr style="onmouseover=this.bgcolor=#ff0000; onmouseout=this.bgcolor=#00ff00;"

Binding is done in C# page

..aspx page code

<%@ Page language="c#" Codebehind="filename.aspx.cs" AutoEventWireup="false" Inherits="filename" %
 
G

Guest

Hi, Michae

First, this is not correct in HTML
<tr style="onmouseover=this.bgcolor=#ff0000; onmouseout=this.bgcolor=#00ff00;"
It should be
<tr onmouseover="this.bgColor='#ff0000';" onmouseout="this.bgColor='#00ff00';""
Which you can add in ItemDataBound Event of the grid, like
void DataGrid2_ItemDataBound(Object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem

e.Item.Attributes("onmouseover") = "this.bgColor='#ff0000'"
e.Item.Attributes("onmouseout") = "this.bgColor='#00ff00'"



Hope this help

Bin Song, MC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top