Paint full row of a grid [closed]

0

I am here to consult the following, I use this to paint on the grid according to the condition I assign, but I am only painting that cell, I would like to paint the entire row, I was looking for information but I did not find if there was one I could give a I would appreciate it, Greetings.

    
asked by Matias Juarez 21.12.2018 в 22:49
source

1 answer

1

You can use the Rows property of gridview to select the entire row instead of column by column. I show a simplified version of a method that I use for such a reason:

protected void PintarGrid(GridView grid, int fila)
{
     grid.Rows[fila].BackColor = Color.Red;
}
  

Update

You can go through the grid row by row, and check for each row if the stock column is at 0, like this:

protected void PintarGrid(GridView grid, int indiceColumna)
        {
            for (int indiceFila = 0; indiceFila < grid.Rows.Count; indiceFila++)
            {
                TableCell campo = grid.Rows[indiceFila].Cells[indiceColumna];
                if (campo.Text.Equals("0"))
                {
                    grid.Rows[indiceFila].BackColor = Color.Red;
                }
            }
        }
    
answered by 21.12.2018 в 22:56