By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,212 Members | 1,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,212 IT Pros & Developers. It's quick & easy.

asp:datagrid style on mouseover mouseout

P: n/a

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" %

Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
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

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.