I would extract the data values into local variables once, and then use the
local variables in the if...else statements.
Looks neater and will give you better performance (because it doesn't have
to retrieve the value for each statement and convert it to an int)
(Note: I've not checked this in VS2005, so I can't guarantee it will compile
and run)
private void fn_setRankingColor(GridViewRow gvr)
{
Label lbl = gvr.FindControl("lbl_RANKINGTODAY") as Label;
int rn = Convert.ToInt32(((DataRowView)gvr.DataItem).Row["RN"]));
int rnp = Convert.ToInt32((((DataRowView)gvr.DataItem).Row["RNP"]));
if( rn == rnp )
{
// Do something
}
else if(rn < rnp )
{
// Do something
}
else
{
// Do something
}
}
HTH
Ged
"WebBuilder451" <We***********@discussions.microsoft.comwrote in message
news:B2**********************************@microsof t.com...
This is what i'm using and it seems way too complicated!! for finding a
data
item.
I hope some one has a better way?
private void fn_setRankingColor(GridViewRow gvr)
{
Label lbl = gvr.FindControl("lbl_RANKINGTODAY") as Label;
if ((Int32)((DataRowView)gvr.DataItem).Row["RN"] ==
(Int32)((DataRowView)gvr.DataItem).Row["RNP"])
{
}
else if ((Int32)((DataRowView)gvr.DataItem).Row["RN"] <
(Int32)((DataRowView)gvr.DataItem).Row["RNP"])
{
lbl.ForeColor = Color.DarkGreen;
lbl.Font.Bold = true;
}
else
{
lbl.ForeColor = Color.DarkRed;
lbl.Font.Bold = true;
}
}
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes