Click here to Skip to main content
14,691,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

Hello , Try this also
Refer : Using JavaScript To Select GridView Rows
thanks
   
Comments
sahmed3 21-Aug-14 11:14am
   
Can you help me in the dynamic Situation to handle the colors on GridView based on Employee Designation.

I have a code over here but unable to get dynamic result as expected.


protected DataSet BindGridView()
{
SqlConnection cnn = new SqlConnection(Conn);
SqlCommand cmd = new SqlCommand("select Employee.EmployeeName,Employee.Designation,Manager.ManagerName"
+ "from Employee Inner join Manager on Employee.EmployeeId=manager.EmployeeId "
", cnn);
SqlDataAdapter ada = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ada.Fill(ds);
return ds;
}


Consider my Table has the Following Records
EmployeeID EmployeeName EmployeeDesignation ManagerName
P001 John Senior.Developer Cena
P002 Brie Associate.Dev Bella
P002 Brock Manager Lesnar

Through Dynamic i need to have a condition if Employee Designation is Manager then Highlight in Blue Color,If Desig=Associate.Dev Highlight in Yellow similarly in Red for Senior.Dev

The above requirement requires while page loads
Maybe this Article will help you

Changing the color of a row in a GridView in ASP.NET[^]
   
Comments
sahmed3 21-Aug-14 11:14am
   
Can you help me in the dynamic Situation to handle the colors on GridView based on Employee Designation.

I have a code over here but unable to get dynamic result as expected.


protected DataSet BindGridView()
{
SqlConnection cnn = new SqlConnection(Conn);
SqlCommand cmd = new SqlCommand("select Employee.EmployeeName,Employee.Designation,Manager.ManagerName"
+ "from Employee Inner join Manager on Employee.EmployeeId=manager.EmployeeId "
", cnn);
SqlDataAdapter ada = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ada.Fill(ds);
return ds;
}


Consider my Table has the Following Records
EmployeeID EmployeeName EmployeeDesignation ManagerName
P001 John Senior.Developer Cena
P002 Brie Associate.Dev Bella
P002 Brock Manager Lesnar

Through Dynamic i need to have a condition if Employee Designation is Manager then Highlight in Blue Color,If Desig=Associate.Dev Highlight in Yellow similarly in Red for Senior.Dev

The above requirement requires while page loads
//Check if it is not header or footer row
if (e.Row.RowType == DataControlRowType.DataRow)
{
    //Check your condition here
    If(Condition True)
    {
        e.Row.BackColor = Drawing.Color.Red // This will make row back color red
    }
}
   
Comments
sahmed3 21-Aug-14 11:14am
   
Can you help me in the dynamic Situation to handle the colors on GridView based on Employee Designation.

I have a code over here but unable to get dynamic result as expected.


protected DataSet BindGridView()
{
SqlConnection cnn = new SqlConnection(Conn);
SqlCommand cmd = new SqlCommand("select Employee.EmployeeName,Employee.Designation,Manager.ManagerName"
+ "from Employee Inner join Manager on Employee.EmployeeId=manager.EmployeeId "
", cnn);
SqlDataAdapter ada = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ada.Fill(ds);
return ds;
}


Consider my Table has the Following Records
EmployeeID EmployeeName EmployeeDesignation ManagerName
P001 John Senior.Developer Cena
P002 Brie Associate.Dev Bella
P002 Brock Manager Lesnar

Through Dynamic i need to have a condition if Employee Designation is Manager then Highlight in Blue Color,If Desig=Associate.Dev Highlight in Yellow similarly in Red for Senior.Dev

The above requirement requires while page loads

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900