• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

If Statement within Formview

Hi,

Looking to write a very simple if statement that would read something like this:

If fieldinformview = "New" then
  cmdAccept.Visible = True
End If

I can't currently find a function that will allow me to pull out the formview's data so that the statement will work.

Help much appreciated.
0
eusaitdept
Asked:
eusaitdept
  • 2
1 Solution
 
strickddCommented:
I think what you're looking for is something like this:

If DirectCast(MyFormView.FindControl("fieldinformview"), TextBox).Text = "New" Then
'Do Something
End If
0
 
eusaitdeptAuthor Commented:
Hi - I've written that code up:

 If DirectCast(FormView1.FindControl("StatusLabel"), TextBox).Text <> "Acc" Then
            Button3.Visible = True
        Else
            Button3.Visible = False
        End If

Open in new window


However receive the following error on loading the page:

System.NullReferenceException was unhandled by user code
  Message=Object reference not set to an instance of an object.
  Source=SocManagerAdmin
  StackTrace:
       at SocManagerAdmin.WebForm4.Page_Load(Object sender, EventArgs e) in \\orthus.ucs.ed.ac.uk\eusahome\abyers1\Visual Studio 2010\Projects\SocManagerAdmin(7)\SocManagerAdmin\pages\devDetails.aspx.vb:line 7
       at System.Web.UI.Control.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException: 

Open in new window



0
 
eusaitdeptAuthor Commented:
Haha! Fixed it, I was looking for a Label not a TextBox so I've changed the code and it's working now, thanks :)
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now