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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top