Object reference not set to an instance of an object.

  • Thread starter Thread starter Jim in Arizona
  • Start date Start date
J

Jim in Arizona

I get the error: Object reference not set to an instance of an object

With this code:

Dim test3 As New TextBox
test3 = CType(e.Item.FindControl("name"), TextBox)
Dim name As String = test3.Text

The specific line is:

Dim name As String = test3.Text

So, what do I need to do to fix that?

Thanks.
 
Because e.Item.FindControl() does not find a control named as "name", hence
next line of code gives you that error.

You need to figure out why there is no TextBox, called "name" found.
 
Yep. That's it. Thanks. Now I have another question to post regarding
this whole mess, which I bet no one will have an answer for.

Thanks Norman.
 
Back
Top