zoukankan      html  css  js  c++  java
  • 实现鼠标悬停高亮显示分别在gridview和datagrid中

    在datagrid中的ItemDataBound事件中写如下代码:
    private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
       
    if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
       {
           e.Item.Attributes.Add(
    "onmouseover","c=this.style.backgroundColor;this.style.backgroundColor='#66CCFF'");
           e.Item.Attributes.Add(
    "onmouseout","this.style.backgroundColor=c");
       }
    }

    在girdview中的RowDataBound事件中写下如下代码:
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            
    if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add(
    "onmouseover""currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff';");
                e.Row.Attributes.Add(
    "onmouseout""this.style.backgroundColor=currentcolor;");
            }
        }

  • 相关阅读:
    [ZOJ 3622] Magic Number
    SGU 134.Centroid(图心)
    SGU 223.Little Kings
    C++ IO 详细用法
    POJ2632 Crashing Robots 解题报告
    POJ1068 Parencodings 解题报告
    POJ3295 Tautology 解题报告
    POJ2586 Y2K Accounting Bug 解题报告
    POJ1328 Radar Installation 解题报告
    POJ3728 The merchant解题报告
  • 原文地址:https://www.cnblogs.com/oec2003/p/738198.html
Copyright © 2011-2022 走看看