> I am trying to check a value of a contril in my gridview but this %$%&^^&*
> thing is driving me nuts.
[quoted text clipped - 8 lines]
> This crap doesn't work. I get either Object not set to instance BS or can
> cast from literal to system.web.ui crap.
I'm not surprised! The above code is indeed crap - I suggest you fire the
idiot who wrote it...
The main problem, of course, is that the cell in question contains a Label
control which the above code is trying to CType to a TextBox...
Dim l As Label = CType(e.Row.Cells(16).FindControl("Status"), Label)
If l.Text = "N" Then
e.Row.Cells(16).Controls(1).Visible = True
e.Row.Cells(16).Controls(0).Visible = False
End If

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
Chris - 05 Sep 2007 15:22 GMT
The code is similar to yours except it was tried against a text box as well.
Even with yours didn't work. Eventually adding .Trim() worked! Pardon my
frustration.
Dim t As TextBox = CType(e.Row.Cells(16).FindControl("Status"),
TextBox)
If t.text.Trim() = "N" Then
e.Row.Cells(16).Controls(1).Visible = True
End If
> > I am trying to check a value of a contril in my gridview but this %$%&^^&*
> > thing is driving me nuts.
[quoted text clipped - 20 lines]
> e.Row.Cells(16).Controls(0).Visible = False
> End If