Highlight Specific row in a gridview [Resolved]

Posted by Self-Innovator under ASP.NET on 8/20/2014 | Points: 10 | Views : 648 | Status : [Member] | Replies : 1
Hi,
I have an requirement in my application i was showing Employee Designations according to their manager level in a GridView Control. Based on Employee Designation i need to have a coloring on every different designations of an employee.

EX:
If employee desig is :Associate->show in Blue color
If employee desig is :Senior Associate->show in Greencolor
If employee desig is :Team Lead->show in Red color

from Stored Procedure.

Join Hands Change lives
Thanks & Regards
Straight Edge Society



Responses

Posted by: Sheonarayan on: 8/20/2014 [Administrator] HonoraryPlatinum | Points: 50

Up
0
Down

Resolved
Call a function inside the TemplateField like this

<%# ChangeColor(Eval("EmpDesignation").ToString(), Eval("Name").ToString()) %>


Define this function in the CodeBehind page like

protected string ChangeColor(string designation, string name)
{
if (designation.Equals("Associate"))
{
return "<span style='color:blue;'>" + name + "</span>";
}
else if (designation.Equals("Associate"))
{
return "<span style='color:green;'>" + name + "</span>";
}
// so on
}


and it should work.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response