我有 21 行的 Gridview 控件。有些行有 0 个值。我的要求是设置背景颜色(包含 0 个值的行)以及隐藏值(意味着 0)。我可以设置背景颜色.But the thing is,I can't able to hide row values.I have written this line of code, gridSellIn.Rows[0].Visible = false; .Total row is hiding.Make sure I have to show rows back ground color without values.Is this possible in asp.net.
最佳答案
在网格中的 RowDataBound 事件中:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (...){
//hide controls
foreach (Control c in e.Row.Controls)
{
c.Visible=false;
}
//change color
e.Row.Style.Add("background-color","red");
}
}
关于c# - 如何在 asp.net 中隐藏 Gridview 行值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14977977/