By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,213 Members | 1,083 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,213 IT Pros & Developers. It's quick & easy.

Access Label in datagrid within DataList

P: n/a
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

Sep 28 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.