pgilfeather
asked on
Passing values from a listbox into a textbox (Driving me crazy!)
This problem is driving me crazy since I know its just a little stupid thing.
I need to know why my code is not working.
All I want to do is pass the selected item in a listbox into a textbox surely this can't be hard?
===================
Here is my listbox
===================
<asp:listbox AutoPostBack="true" DataValueField="QuestionID " Height="500" ID="lstQuestions" runat="server" SelectionMode="single" Width="70" OnSelectedIndexChanged="Te sting"></a sp:listbox >
==================
Here is a test procedure
==================
Sub Testing(ByVal sender As System.Object, ByVal e As System.EventArgs)
lblDisplay.Text = lstQuestions.SelectedItem. Text
End Sub
==================
Here is the error message
==================
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.NullReferenceExcept ion: Object reference not set to an instance of an object. (WHAT DOES THIS MEAN?)
=====================
Please note
========
I am using Dreamweaver MX, not visual studio
I am using VB.NET
Your help getting through this error will be much apreciated.
The listbox contains a numeric ID
Thanks
PG
I need to know why my code is not working.
All I want to do is pass the selected item in a listbox into a textbox surely this can't be hard?
===================
Here is my listbox
===================
<asp:listbox AutoPostBack="true" DataValueField="QuestionID
==================
Here is a test procedure
==================
Sub Testing(ByVal sender As System.Object, ByVal e As System.EventArgs)
lblDisplay.Text = lstQuestions.SelectedItem.
End Sub
==================
Here is the error message
==================
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.NullReferenceExcept
=====================
Please note
========
I am using Dreamweaver MX, not visual studio
I am using VB.NET
Your help getting through this error will be much apreciated.
The listbox contains a numeric ID
Thanks
PG
Have you tried setting .EnableViewState = True for the listBox?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry, forgot to put;
If not Page.Ispostback in.
If not Page.Ispostback in.