Access Label control in datagrid within datalist

D

DKode

Ok,

This seems like it should be simple, but everytime I access the label,
it's text property is always set to "". Here is the code I am using:

private void dgrComputer_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e) {
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem) {
Label lbl = (Label)e.Item.FindControl("lblStatus");

if (lbl.Text == "True") {
e.Item.BackColor = Color.Green;
}
else {
e.Item.BackColor = Color.Red;
}
}
}

I am trying to do conditional processing to change the background color
of the row, I can access the label, but its text property is always set
to "". I have also tried accessing it by using
e.Item.Cells[0].FindControl and a multitude of other different ways but
always with the same results. Does anyone have ideas? this is driving
me up the wall.

thank you
Sean
 

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

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top