Solved

Passing values from a listbox into a textbox (Driving me crazy!)

Posted on 2004-08-26
3
290 Views
Last Modified: 2010-05-18
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="Testing"></asp: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.NullReferenceException: 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
0
Comment
Question by:pgilfeather
  • 2
3 Comments
 
LVL 6

Expert Comment

by:pillbug22
Comment Utility
Have you tried setting .EnableViewState = True for the listBox?
0
 
LVL 6

Accepted Solution

by:
pillbug22 earned 500 total points
Comment Utility
And if your listBox is being filled by a dataSource, are you re-filling it on PostBack (before the sub fires)?
0
 

Author Comment

by:pgilfeather
Comment Utility
Sorry, forgot to put;

 If not Page.Ispostback in.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
for loop with Set 4 45
How to split this in C++ 4 76
wordlen challenge 3 46
Adoquery sql  left join does not work 25 44
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
A short article about a problem I had getting the GPS LocationListener working.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now