View Single Post
  #7 (permalink)  
Old January 23rd, 2008, 11:03 AM
dparsons dparsons is offline
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

That leads me to believe that lstIPC.SelectedItem returns null.

This will depend on your program flow but if your page load looks like this:

Protected Sub Page_Load(sender as Object, e as EventArgs)
   DataBindList()
End Sub

It needs to be
Protected Sub Page_Load(sender as Object, e as EventArgs)
   If Not Page.IsPostBack Then
       DataBindList()
   End If
End Sub

Otherwise you will rebind your list on postback and all of the selections you have made in the list box will be gone, resulting in the Null Reference.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
Reply With Quote