关于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;
}
}
此事件还可以定义鼠标经过和离开时的颜色
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;
}
}
相关文章推荐
- ASP.NET MVC企业级项目框架搭建实战
- asp.net mvc 之旅—— 第三站 路由模板中强大的自定义IRouteConstraint约束
- asp.net 文件复制或删除用相对路径,File.Copy中用相对路径,巧用相对路径复制文件
- Aspose.cell
- Asp.net 一般处理程序.ashx中对Session的操作
- Modifying the ASP.NET Request Queue Limit
- 【无私分享:从入门到精通ASP.NET MVC】从0开始,一起搭框架、做项目(7.2) 模块管理,模块的添加、修改、删除
- ASP.NET 点击前台服务器按钮后, 刷新. 重新执行 按钮事件
- asp.net mvc 在View中获取Url参数的值
- ASP.NET资料搜集
- vs项目属性中目标平台x86,x64,any cpu的区别
- win10下vs2015创建asp,net core项目并运行在ubuntu14.04下
- 【AspNet Core】Nuget代理网站
- Dotnetnuke安装
- .net mvc web api上传图片/文件并重命名
- ubuntu 下安装metasploit
- ASP.NET里的Session详细解释
- ASP.NET多次点击提交按钮以及Session超时和丢失过期问题
- 【译】Asp.net mvc 使用ITextSharp PDF to HTML (解决img标签问题)
- Java整合Sikuli和Asprise.OCR实现桌面自动化