我想为特定的gridview颜色行着色 [英] I want to color specific row of gridview color in
本文介绍了我想为特定的gridview颜色行着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果Gridview的第一个单元格包含值
I want to change color of row of Gridview if Its first cell contain value
Total Corporate
,
Total SME
,我想更改Gridview行的颜色,
,
Grand Total
但未将其应用于gridview
我尝试过:
我创建了存储过程来从数据库中获取值。
并将sp绑定到gridview。它显示了gridview上的所有值。
现在改变特定行的颜色我在
but is not applying it to gridview
What I have tried:
I have created stored procedure to Get values from database.
and bind that sp to gridview. it showing all values on gridview.
now to chang color of specific row i have written code in
GridView1_RowDataBound(
gridview事件为
event of gridview as
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[0].Text == "Total Corporate") // but here it showing text as null i.e ""
{
e.Row.BackColor = System.Drawing.Color.Red; }
}
}
但这里显示
but here it showing
text value as ""
if (e.Row.Cells[0].Text == "Total Corporate")
and it is not applying color on Gridview Row
推荐答案
我工作MVC,所以事情的方式不同。但是,快速 Google搜索(asp.net c#gridview条件格式) [ ^ ]出现了这个接受的解决方案,所以它应该可以解决你的问题:
* c# - 如何在GridView中实现条件格式 - Stack Overflow [ ^ ]
I work MVC, so things are done differently. However, a quick Google Search (asp.net c# gridview conditional formatting)[^] turned up this accepted solution, so it should solve your problem:
* c# - How to implement conditional formatting in a GridView - Stack Overflow[^]
这篇关于我想为特定的gridview颜色行着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文