Grid View

B

bbawa1

In my prject I used the stored procedure which I sent you ealier which
calculates the date differnce also.
..I attached that datasource to gridview. my gridview looks like this.

Css Field received
Id Wait Time
6/13/2007 12:38 am
1123 3d 21h 45m
6/13/2007 10:45
1124 2d 30h 07m


In "CssField" in GridView I have to use colors based on the following
condidtion
If Wait Time >= 24 hours then color = Red
= 20 hours Orange
= 16 hours yellow


Also How can I use the above condition for putting different colors in
all rows based on WaitTime field.

The following is my CSS class.

..sdgStatusRed {
background-color: Red;
height: 25px;
width: 25px;
}

..sdgStatusOrange {
background-color: Orange ;
height: 25px;
width: 25px;
}

..sdgStatusYellow {
background-color: Yellow;
height: 25px;
width: 25px;
}

..sdgStatusGreen {
background-color: Green;
height: 25px;
width: 25px;
}

..sdgStatusBlue {
background-color: Blue;
height: 25px;
width: 25px;
}
 
M

marss

In my prject I used the stored procedure which I sent you ealier which
calculates the date differnce also.
.I attached that datasource to gridview. my gridview looks like this.

Css Field received
Id Wait Time
6/13/2007 12:38 am
1123 3d 21h 45m
6/13/2007 10:45
1124 2d 30h 07m


In "CssField" in GridView I have to use colors based on the following
condidtion
If Wait Time >= 24 hours then color = Red


Also How can I use the above condition for putting different colors in
all rows based on WaitTime field.

The following is my CSS class.

.sdgStatusRed {
background-color: Red;
height: 25px;
width: 25px;
}

.sdgStatusOrange {
background-color: Orange ;
height: 25px;
width: 25px;
}

.sdgStatusYellow {
background-color: Yellow;
height: 25px;
width: 25px;
}

.sdgStatusGreen {
background-color: Green;
height: 25px;
width: 25px;
}

.sdgStatusBlue {
background-color: Blue;
height: 25px;
width: 25px;
}

Hi,

You can do it in RowDataBound event handler.
e.g.
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//e.Row.DataItem contains data that is bound to the current row.
//I guess in your case it is a row of data table.
DataRowView data = (DataRowView)e.Row.DataItem;

//Here you can get value of WaitTime through data["WaitTime"].
//Than based on WaitTime set back color of first cell ("Css
Field" column)
// e.Row.Cells[0].CssClass = "sdgStatusRed";
}
}

Regards, Mykola
http://marss.co.ua
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top