Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

I need your assistance please

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 04 Sep 2007 23:42 GMT
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
Mark Rae [MVP] - 05 Sep 2007 00:21 GMT
> 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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.