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

I need your assistance please

P: n/a
Hi,
I am trying to check a value of a contril in my gridview but this %$%&^^&*
thing is driving me nuts.

I tried

Dim t As TextBox = CType(e.Row.Cells(16).FindControl("Status"), TextBox)
If t.text = "N" Then
e.Row.Cells(16).Controls(1).Visible = True
End If

This crap doesn't work. I get either Object not set to instance BS or can
cast from literal to system.web.ui crap.

The column is a template column with 2 controls, one label control and
another is a checkbox. I want to set the checkbox to visible only when the
label control says "N" and at the same time make the label contril visible =
flase.

Please assist.

Thanks

Sep 4 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:60**********************************@microsof t.com...
I am trying to check a value of a contril in my gridview but this %$%&^^&*
thing is driving me nuts.

I tried

Dim t As TextBox = CType(e.Row.Cells(16).FindControl("Status"), TextBox)
If t.text = "N" Then
e.Row.Cells(16).Controls(1).Visible = True
End If

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
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 4 '07 #2

P: n/a
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
"Mark Rae [MVP]" wrote:
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:60**********************************@microsof t.com...
I am trying to check a value of a contril in my gridview but this %$%&^^&*
thing is driving me nuts.

I tried

Dim t As TextBox = CType(e.Row.Cells(16).FindControl("Status"), TextBox)
If t.text = "N" Then
e.Row.Cells(16).Controls(1).Visible = True
End If

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
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 5 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.