zoukankan      html  css  js  c++  java
  • GridView鼠标移动到某一行时行发生变色和为Gridview中编辑模板中的控件添加颜色

     

    protected void GvFloorList_RowDataBound(object sender, GridViewRowEventArgs e)//该方法一定要启用RowDataBound事件
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //当鼠标停留时更改背景色
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#bcdbec';");
                //当鼠标移开时还原背景色
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
                //设置悬浮鼠标指针形状为“下手”
                e.Row.Attributes["style"] = "cursor:pointer";

                //设置是否有效颜色样式 ==================================================================================
                Label hidIsValid = e.Row.FindControl("LblIsValid") as Label;
                Label lblIsValidText = e.Row.FindControl("LblIsValidValue") as Label;

                ////有效:绿色
                if (hidIsValid.Text == "1")
                {
                    lblIsValidText.ForeColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.Green);
                }
                //无效:红色
                else
                {
                    lblIsValidText.ForeColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.Red);
                }
                //======================================================================================================
            }
        }

  • 相关阅读:
    LeetCode First Bad Version (二分查找)
    LeetCode Permutations II (全排列)
    LeetCode Permutations (全排列)
    LeetCode Minimum Path Sum (简单DP)
    LeetCode Binary Tree Postorder Traversal(数据结构)
    LeetCode Sort Colors (技巧)
    邹忌
    参数传递
    父子窗体返回值与互操作
    其他数据库连接
  • 原文地址:https://www.cnblogs.com/lzhp/p/2680812.html
Copyright © 2011-2022 走看看