?
Solved

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

Posted on 2004-08-26
3
Medium Priority
?
327 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 6

Expert Comment

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

Accepted Solution

by:
pillbug22 earned 2000 total points
ID: 11902527
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
ID: 11902921
Sorry, forgot to put;

 If not Page.Ispostback in.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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 …
Simple Linear Regression
Suggested Courses

770 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