您的位置:首页 > 编程语言 > ASP

关于Asp.net中GridView控件不显示部分列数据的方法

2016-05-31 15:09 603 查看
在GridView的RowCreated事件中设置e.Row.Cells[16].Visible = false;

此事件还可以定义鼠标经过和离开时的颜色

e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#eaeaea';");//这是鼠标移到某行时改变某行的背景 

        e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;");//鼠标移走时恢复 

另外,在GridView的RowDataBound事件中,可以判断单元格数值来调整行颜色

protected void gv_function_RowDataBound(object sender, GridViewRowEventArgs e)

    {

        if (e.Row.Cells[7].Text.Trim() != "1")

        {

            e.Row.BackColor = System.Drawing.Color.Red;

        }

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: