I have a listview with an EditTemplate. If I have one item in the listview, the following code throws a null exception:
if((TextBox)this.lvwColors.EditItem.FindControl("txtColor")) != null)
{
this.Color =
((TextBox)this.lvwColors.EditItem.FindControl("txtColor")).Text.Trim();
}
It does not throw an error if I have two items in my listview.
The other strange thing is that it only throws an error when on a production server, but when I am testing locally, I do not get the error. Does anyone know why this behavior might exist?
Here is EditTemplate part of the markup:
<EditItemTemplate>
<asp:TextBox ID="txtColor" runat="server"
Text='<%# Eval("Color").ToString().Trim() %>'
</EditItemTemplate>