这可能吗?我只能设置单元格的背景颜色。问题是,如果我设置了背景色,当您打印页面时它不会显示(默认情况下)。所以我想通过 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/