W
William F. Robertson, Jr.
Would you post your code for lstProduct_SelectedIndexChanged()?
bill
Hello, Folks!!
Here's the problem:
.. ASP.NET 1.1
.. Running on Windows Server 2000
.. Using WebMatrix to write the code...and sometimes Notepad!
.. 2 Web Objects (ListBoxes) in question
.. Information pulled from MS-SQL server through DataReader
In my application / page I have a listbox, lstCategory, that is
automatically populated when the page is loaded. Based on the selection
from lstCategory it will fill another listbox, lstProduct. When the user
selects from lstProduct it goes and does other things.
When my application tries to populate lstProduct after selecting fom
lstCategory I get the error, "System.NullReferenceException. Object
reference not set to an instance of an object. An unhandled exception..."
With the stack trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
Product.lstProduct_SelectedIndexChanged(Object sender, EventArgs e) +49
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)
+108
System.Web.UI.WebControls.ListBox.System.Web.UI.IPostBackDataHandler.RaisePo
stDataChangedEvent() +26
System.Web.UI.Page.RaiseChangedEvents() +115
System.Web.UI.Page.ProcessRequestMain() +1081
What the Fudge!?!
I have tried searching for a solution on various sites but no luck, yet.
I know what triggers the problem. Before I populate lstProduct I perform
the command lstProduct.Items.Clear() to clear the list. When I comment out
the line it works fine but keeps adding to lstProduct with a whole bunch of
values that shouldn't be there. Any insights are welcome.
TIA.
Here's some of the code:
' Product.vb
'
Imports Microsoft.VisualBasic
Imports blah, blah, blah.
Public Class Product
'For PostBack
Inherits Page
Protected WithEvents lstCategory as ListBox
Protected WithEvents lstProduct as ListBox
bill
Hello, Folks!!
Here's the problem:
.. ASP.NET 1.1
.. Running on Windows Server 2000
.. Using WebMatrix to write the code...and sometimes Notepad!
.. 2 Web Objects (ListBoxes) in question
.. Information pulled from MS-SQL server through DataReader
In my application / page I have a listbox, lstCategory, that is
automatically populated when the page is loaded. Based on the selection
from lstCategory it will fill another listbox, lstProduct. When the user
selects from lstProduct it goes and does other things.
When my application tries to populate lstProduct after selecting fom
lstCategory I get the error, "System.NullReferenceException. Object
reference not set to an instance of an object. An unhandled exception..."
With the stack trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
Product.lstProduct_SelectedIndexChanged(Object sender, EventArgs e) +49
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)
+108
System.Web.UI.WebControls.ListBox.System.Web.UI.IPostBackDataHandler.RaisePo
stDataChangedEvent() +26
System.Web.UI.Page.RaiseChangedEvents() +115
System.Web.UI.Page.ProcessRequestMain() +1081
What the Fudge!?!
I have tried searching for a solution on various sites but no luck, yet.
I know what triggers the problem. Before I populate lstProduct I perform
the command lstProduct.Items.Clear() to clear the list. When I comment out
the line it works fine but keeps adding to lstProduct with a whole bunch of
values that shouldn't be there. Any insights are welcome.
TIA.
Here's some of the code:
' Product.vb
'
Imports Microsoft.VisualBasic
Imports blah, blah, blah.
Public Class Product
'For PostBack
Inherits Page
Protected WithEvents lstCategory as ListBox
Protected WithEvents lstProduct as ListBox