Special effects...

liunx

Guest
I have a GrideView that t display some customer data related to problem calls. Within this table is a column called 'Status'. There are four different levels of status: Open - In-Progress - Urgent - Closed. What I would like to do is have the text color of the issue change depending on what status level it is at. For instance, if the status is:
Open - Black
In-Progress - Green
Urgent - Red
Closed - Not visible (Handled within the sql-script)

Can some give me an Idea of how I can accomplish this?

My table name is CTPT and the column name is Status. I managed to scrounge up the following script but don't know how to taylor it to my needs:

This script was designed for traditional asp.net not .net 2.0. I am using a GridView component.

DataGridItem dgItem;
foreach (int dgItem in Dg1.Items) {
if (condition1) {
dgItem.Cells(0).ForeColor = Color.Black;
} else if (condition2) {
dgItem.Cells(0).ForeColor = Color.Green;
} else if (condition3) {
dgItem.Cells(0).ForeColor = Color.Red;
} else {
}
}
Thank you for your help.

Sincerely,
MustangI found another script and have started to incoporate it into my code-behind:

void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// determine the value of the UnitsInStock field
DataBinder.Eval(e.Row.DataItem,
"Status");
if (Status == Closed)
// color the background of the row yellow
e.Row.ForeColor = Color.Red;
}
}

I get an error stating that:

The name 'Status' does not exist in the current context

Any ideas?

Thanks.What is the 'Status'? Is it the 'Status' property of your connection object?What is the 'Status'? Is it the 'Status' property of your connection object?

Status is merely the results set within a column of a table called CTPT. In other words, Status reflects the current choice made by a user to identify the current position of a customer call tracking record. The user choices are either Open - In-Progress - Urgent - Closed.

I hope this answers your question.

Thank you for your help.

MustangI recently worked on an on-call schedule that used a different color for each person on call. Since you are using sql already, why not add a column to your table called StatusColor. Then bind the color setting of your control to that field in the row of the dataset you are working with?...

That way you can change the color at will with out having to deploy your app.You need to get a reference of the 'status' before you can use that.

I dont know what is holding the status, but let say its a label, and the ID is lblStatus.


String a = ((Label) e.FindControl("lblStatus")).Text
if (a = "Closed")
{ blah blah blah }

Tak
 
Back
Top