I have a grid view which contains some sequence numbers. Each column needs to have unique number sequence. It is editable and if the user input number which is already in this particular column the cells are colored in red.
So far I color only the second cell of the 2 wrong cells (with same values). How can I color both cells. As far as I know I need to use the row index as well but I have no idea how..
Here is the code
//colum2
string sValue2 = e.Row.Cells[4].Text;
if (Values2.Contains(sValue2))
{
// This value is a duplicate - color red
e.Row.Cells[4].BackColor = System.Drawing.Color.Red;
//Response.Write("Warning... Error in pad no: " +e.Row.Cells[2].Text+ " dupliated value: " +e.Row.Cells[3].Text);
}
else
{
Values2.Add(sValue2);
}
and the same for all the 8 columns
Hopefully it’s understandable.
Thanks a lot in advance
If I get your question right, you would like to find out the RowIndex for the row which already contains the same data in the same cell, and change it’s color to red.
You could write a method to change every cells color to red which contains that data.
Something like:
And then you could use like this: