• 实现鼠标悬停高亮显示分别在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;");
            }
        }

  • 相关阅读:
    C#读取EXCEL中数字无法读取的方法
    学习Wml
    sqlserver.exe进程占cpu100%
    windows phone mango 页面跳转事件顺序
    Windows 8 系列(一):win 8 简介
    windows phone 小应用与随机算法的感悟
    文件下载
    html 表格固定宽度
    excel 导入科学计数法
    word 排版
  • 原文地址:https://www.cnblogs.com/oec2003/p/738198.html
Copyright © 2020-2023  润新知