asp:datagrid style on mouseover mouseout

Discussion in 'ASP .Net' started by Guest, May 18, 2004.

  1. Guest

    Guest 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" %
     
    Guest, May 18, 2004
    #1
    1. Advertisements

  2. Guest

    Guest 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
     
    Guest, May 18, 2004
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.