how to compare coloumn values in grid view

Posted by Srinivasulu.enugu under ASP.NET on 5/28/2011 | Points: 10 | Views : 4714 | Status : [Member] | Replies : 1
hi friends,

i have one grid view control in my .aspx page it contains four coloumns..
i have to compare one of the coloumn values... how to coampare plz tell me it seems like below....

eventtype
5
6
7
1
2
like this if event type=5 then cell colour =red ,if eventtype=2 then cell colour=yellow. how to get it. plz tell me ....

Srinivasulu Enugu


Responses

Posted by: Prabhakar on: 5/30/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi
Create GridView1_RowDataBound event for your GridView.

if (e.Row.RowType = DataControlRowType.DataRow)

{
//Check your condition here
int type;
If(type == e.Row.Cells[1].Text )
{
e.Row.BackColor = Drawing.Color.Red // This will make row back color red
}
}


try it ... it's work for u . .


Best Regard's
Prabhakar

Srinivasulu.enugu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response