c# - 是否可以设置 asp.net gridview 单元格的背景?

标签 c# asp.net css gridview

这可能吗?我只能设置单元格的背景颜色。问题是,如果我设置了背景色,当您打印页面时它不会显示(默认情况下)。所以我想通过 css 将背景设置为网格单元格,但在 BoundField.ItemStyle 类中找不到此属性(仅“backgroundColor”)。那么,这有可能吗?

提前致谢

最佳答案

你可以试试

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if(e.Row.RowType == DataControlRowType.DataRow)
    {

      if(condition)//Replace with your condition
      {
        e.Row.Cells[5].Attributes.Add("Style", "background: url(../Images/test.png) no-repeat 5px center
      }
    }
}

关于c# - 是否可以设置 asp.net gridview 单元格的背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12375382/

相关文章:

c# - 尝试发布 SQL CLR 数据库的日期时间类型不匹配

asp.net - SQL Server、Cosmos/文档数据库、身份成员资格和多语言持久性

css - Symfony2 表单类型 - 如何将表单 CSS 类设置为属性?

javascript - CSS 和 JS : How to Inflate the Size of a Tile In Grid

asp.net - 将现有的 .net 功能扩展到 iPad

javascript - 有没有更有效的方式来显示 DOM 元素

c# - Blazor 服务器文件上传静默崩溃服务器

c# - ASP.NET MVC5 WebAPI2 防止未经授权重定向到登录页面

c# - WPF:如何在运行时更改 CurrentUICulture

asp.net - 不同机器上相同文化的不同 DateTimeFormat