I'm using the DrawItem event of a DataRepeater to change the .BackColor and .ForeColor of a textbox based on the .Text contents. This works just fine UNLESS the textbox is located on a panel. If the textbox is on a panel, then I am returning this exception: "Object reference not set to an instance of an object." It indicates that "e.DataRepeaterItem.Controls(txt_AWQRecordStatus.Name).Text" doesn't have a value. Stepping through the code confirms it.
BUT... if I just slide that textbox off the panel, then it works just fine. My Google-Fu has failed me. What am I missing?
Additional Info: Visual Studio 2010 Professional, VB.Net targeting.NET 4.0
'Set Record Status Color
Select Case e.DataRepeaterItem.Controls(txt_AWQRecordStatus.Name).Text
Case "Working"
e.DataRepeaterItem.Controls(txt_AWQRecordStatus.Name).BackColor = Color.Green
e.DataRepeaterItem.Controls(txt_AWQRecordStatus.Name).ForeColor = Color.White
Case "Sleep"
e.DataRepeaterItem.Controls(txt_AWQRecordStatus.Name).BackColor = Color.Red
e.DataRepeaterItem.Controls(txt_AWQRecordStatus.Name).ForeColor = Color.White
Case Else
e.DataRepeaterItem.Controls(txt_AWQRecordStatus.Name).BackColor = Color.White
e.DataRepeaterItem.Controls(txt_AWQRecordStatus.Name).ForeColor = Color.Black
End Select