ASP.NET passing values


S

somersbar

im trying to transfer data from one webform to another.
can anyone help me with the error im getting from webform1 on line 84
of my code?

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Source Error:


Line 82:
Line 83: Private Sub DropDownList2_SelectedIndexChanged(ByVal
sender As System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged, DropDownList2.SelectedIndexChanged
Line 84: Session("cinemaName") =
DropDownList2.SelectedItem.Text
Line 85: Server.Transfer("WebForm2.aspx")
Line 86: End Sub


this is the code in webform2:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Label1.Text = Session("areaName")
End Sub
 
Ad

Advertisements

S

slagomite

It means just what it says -- something's not instantiated. in this
case, either DropDownList2, or its SelectedItem property.

One thing to check is that your server control variable is declared as
"protected" -- any other modifier will cause ASP.NET to not recognize
it as the corresponding control in your HTML.

HTH
Luke
 
S

somersbar

ive been tryin to fix it but still stuck. it is 'protected' anyway so
thats not it. i really have no clue wats wrong. im trying an example
now with a listbox. when i run the webform i can see all the values in
the listbox but when i select one and try a simple thing like sending
that selected item to a textfield even in the same form i get the same
error from this line of code:

TextBox1.Text = ListBox1.SelectedItem.Text
 
Ad

Advertisements

G

Guest

Put a breakpoint on line 84. Examine all variables in the Immediate window as;

?variableName is nothing

See what isn't instantiated.
 

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

Top