gpt4 book ai didi

c# - 如何在 asp.net 中隐藏 Gridview 行值

转载 作者:行者123 更新时间:2023-11-30 15:35:26 27 4
gpt4 key购买 nike

我有 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. enter image description here

最佳答案

在网格中的 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com