Hello,
I have two ASP pages (1 and 2). When I am closing 2, I want to populate a Listbox in 1 using data in page 2.
I am adding data in the Listbox through a Method as the Control is protected and can not directly access it. When the method is called I get the following error in page 1:
Object reference not set to an instance of an object.
Code Behind Class 1:
Public Class One
Protected WithEvents lstBox As System.Web.UI.WebControls.ListBox
Public Sub AddList(ByVal lstItem As String)
lstBox.Items.Add(lstItem)
End Sub
End class
Code Behind Class 2:
Imports Project.One
Public Sub btnClose_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim clsOne As New Project.One()
If DataGrid.Items.Count <> 0 Then
Dim item As DataGridItem
For Each item In DataGrid.Items
clsOne.AddList(item.Cells(1).Text)
Next item
End If
Response.Write("<Script Language='Javascript'>window.close();</script>"
End Sub
Don't know how to instantiate the Listbox. If I use the keyword New in the declaration of the listbox, get no errors, but it's not working.
Thanks for your help.
I have two ASP pages (1 and 2). When I am closing 2, I want to populate a Listbox in 1 using data in page 2.
I am adding data in the Listbox through a Method as the Control is protected and can not directly access it. When the method is called I get the following error in page 1:
Object reference not set to an instance of an object.
Code Behind Class 1:
Public Class One
Protected WithEvents lstBox As System.Web.UI.WebControls.ListBox
Public Sub AddList(ByVal lstItem As String)
lstBox.Items.Add(lstItem)
End Sub
End class
Code Behind Class 2:
Imports Project.One
Public Sub btnClose_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim clsOne As New Project.One()
If DataGrid.Items.Count <> 0 Then
Dim item As DataGridItem
For Each item In DataGrid.Items
clsOne.AddList(item.Cells(1).Text)
Next item
End If
Response.Write("<Script Language='Javascript'>window.close();</script>"
End Sub
Don't know how to instantiate the Listbox. If I use the keyword New in the declaration of the listbox, get no errors, but it's not working.
Thanks for your help.