I am having a problem with a page that I am trying to develop=2E I=
am new at asp=2Enet=2E
The page I have created makes a datagrid that has two links a=
edit and a cancel link=2E When you click either of the links it=
throws the following error "Object reference noet set to an=
instance of an object=2E The following lines appear along with=
that error message
Line 69: Dim CurrentTextBox As=
System=2EWeb=2EUI=2EWebControls=2ETextbo
x
Line 70: CurrentTextBox=3DE=2EItem=2EFindControl(
"edit_" &=
Cols(I))
Line 71: Dim ColValue As String =3D CurrentTextBox=2EText
Line 72: MyCommand=2EParameters("@dotnet.itags.org." &=
Cols(I))=2EValue=3DColValue
Line 73: Next
I forgot to mention that this is part of a For Next Loop
What could be causing this--I can post more code if needed
Thank you in advance
Max
--
From: Max Gay
Posted by a user from =2ENET 247 (http://www=2Edotnet247=2Ecom/)
<Id>2jeCOwwgHEGeAglBD0PF4Q=3D=3D</Id>Okay, Max, let's walk through this, and see what the possible candidates
are. In case you're not sure, this exception means that you've tried to
treat some variable that is null (Nothing) as an object of the type that you
thought it was.
Line 69: Dim CurrentTextBox As System.Web.UI.WebControls.Textbox
This line declares a variable. There is no object reference here, only a
type reference.
Line 70: CurrentTextBox=E.Item.FindControl("edit_" & Cols(I))
This line assigns the result of the FindControl method to your variable. It
could not throw an exception, because if the object is not found, the method
returns null (Nothing). That is a valid value for any object variable.
Line 71: Dim ColValue As String = CurrentTextBox.Text
This is a very likely candidate. You can't treat Nothing like a TextBox. It
has no TextBox properties. In fact, it has no properties at all. However,
there is one other possibility:
Line 72: MyCommand.Parameters("@." & Cols(I)).Value=ColValue
If MyCommand is Nothing, or MyCommand.Parameters is Nothing, or
MyCommand.Parameters("@." & Cols(i)) is Nothing, this could also be the
offending line.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.
"Max Gay via .NET 247" <anonymous@.dotnet247.com> wrote in message
news:OMA8PEsaFHA.1088@.TK2MSFTNGP14.phx.gbl...
I am having a problem with a page that I am trying to develop. I am new at
asp.net.
The page I have created makes a datagrid that has two links a edit and a
cancel link. When you click either of the links it throws the following
error "Object reference noet set to an instance of an object. The following
lines appear along with that error message
Line 69: Dim CurrentTextBox As System.Web.UI.WebControls.Textbox
Line 70: CurrentTextBox=E.Item.FindControl("edit_" & Cols(I))
Line 71: Dim ColValue As String = CurrentTextBox.Text
Line 72: MyCommand.Parameters("@." & Cols(I)).Value=ColValue
Line 73: Next
I forgot to mention that this is part of a For Next Loop
What could be causing this--I can post more code if needed
Thank you in advance
Max
--
From: Max Gay
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>2jeCOwwgHEGeAglBD0PF4Q==</Id>
0 comments:
Post a Comment