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

标签 c# asp.net .net vb.net

我有 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/

相关文章:

asp.net - 如何将 ASP.NET 母版页存储在公共(public)库中?

sql - 使用 "NOT IN"的 LINQ to SQL 查询

c# - "GetBy"Web API中的方法

c# - 不存在数据时尝试读取无效

c# - 以编程方式编辑 IIS IPGrant 表

c# - 如何使用 ConfigurationManager.AppSettings

c# - Expression.Block() 可以在 lambda 闭包中返回一个值吗?

c# - Caliburn.Micro 将 View 模型与 ItemsControl 绑定(bind)列表

c# - 如何将这段代码重写为LINQ?

C# : Some questions about a method which allows to display a label for a specific time