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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top