如果值相同,则为gridview单元格 [英] Color gridview cell if same values

查看:76
本文介绍了如果值相同,则为gridview单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想在网格视图颜色中更改单元格的颜色

gridview单元格如果该单元格的值相同。



请提供相同的代码。



谢谢



Rps

Hi,

I want to change the color of the cell in Grid View Color
gridview cell if same values of that cell.

Please provide the code for the same.

Thank you

Rps

推荐答案

for (int i = 0; i < GridView1.Rows.Count-1; i++)
       {
           for (int j = 0; j < GridView1.Rows[i].Cells.Count-1; j++)
           {
               if (GridView1.Rows[i].Cells[j]!=null)
               {
                   GridView1.Rows[i].Cells[j].BackColor = "Pink";
               }
           }
       }





这将以任何方式帮助你/>
你可以在永远你的逻辑适合的地方打电话..

Happy COdInG:)



This Will Help You any ways
You can call this where Ever Your Logic Fits..
Happy COdInG:)


hi。



这是我的代码,我的价值部分是从gridview中每行的第3个单元格开始。





protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs e)

{

if(e.Row.RowType == DataControlRowType.DataRow)

{

for(int i = 3; i< e.Row.Cells.Count; i ++)

{

Double ListPrice = Double。 Parse(e.Row.Cells [i] .Text);

if(ListPrice< 60)

{

e.Row。 Cells [i] .BackColor = System.Drawing.Color.Red;

}

else if(ListPrice> 60)

{

e.Row.Cells [i] .BackColor = System.Drawing.Color.Green;

}

}

}

}
hi.

this is my code, my value part is start from 3rd cell of each row in gridview.


protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 3; i < e.Row.Cells.Count; i++)
{
Double ListPrice = Double.Parse(e.Row.Cells[i].Text);
if (ListPrice < 60)
{
e.Row.Cells[i].BackColor = System.Drawing.Color.Red;
}
else if (ListPrice > 60)
{
e.Row.Cells[i].BackColor = System.Drawing.Color.Green;
}
}
}
}


这篇关于如果值相同,则为gridview单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆