使用 1 更改所有单元格的单元格颜色
Change cell colour on all cells with 1
我正在尝试更改所有值为“1”的单元格的颜色
它位于带有数据绑定列的 gridview 上
看起来像这样
我试过的代码是这样的,但是它改变了数字比“1”更多的单元格
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (e.Row.Cells[i].Text.ToLower().IndexOf("1") > -1)
{
e.Row.Cells[i].ForeColor = System.Drawing.Color.Red;
}
}
}
}
Protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (e.Row.Cells[i].Text.Equals("1"))
{
e.Row.Cells[i].ForeColor = System.Drawing.Color.Red;
}
}
}
}
我正在尝试更改所有值为“1”的单元格的颜色
它位于带有数据绑定列的 gridview 上
看起来像这样
我试过的代码是这样的,但是它改变了数字比“1”更多的单元格
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (e.Row.Cells[i].Text.ToLower().IndexOf("1") > -1)
{
e.Row.Cells[i].ForeColor = System.Drawing.Color.Red;
}
}
}
}
Protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (e.Row.Cells[i].Text.Equals("1"))
{
e.Row.Cells[i].ForeColor = System.Drawing.Color.Red;
}
}
}
}