Hi all,
I have a table with 6 rows and 5 columns. First row is the header, I want to change color for the values in the 5th column, i.e. if the value is >0 then the font color is red, if value is <0 then its green.
I have a code, buts its not working on my page.
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridView1.DataBind();
int XZ = Convert.ToInt32(Convert.ToInt32(GridView1.Rows[1].Cells[4].Text));
if (XZ > 0)
{
GridView1.Rows[1].Cells[4].ForeColor = Color.LimeGreen;
}
else if (XZ < 0)
{
GridView1.Rows[1].Cells[4].ForeColor = Color.Red;
}
else if (XZ == 0)
{
GridView1.Rows[1].Cells[4].ForeColor = Color.Black;
}
}
and this is my aspx page code:
<asp:GridView ID="GridView1" runat="server" BackColor="LightGray" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" ForeColor="Black" Height="139px" Width="210px" AutoGenerateColumns="False" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" >
Please guide me to fix this issue, as I am a net admin, and our developer is on vacation. If urgent to fix it as we already are hosting these table on our site.
Thank you.