M
Microsoft
I have the following sub inside a usercontrol that is called when a
hyperlink is loaded using the OnLoad = hlViewCart_Load (below) that accesses
a session variable to get the text for the link but, I get the following
error:
Object reference not set to an instance of an object.
Public Sub hlViewCart_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles hlViewCart.Load
Dim sessionCart As DataTable = CType(Session("cart"), DataTable)
Dim dtCount As String = CStr(sessionCart.Rows.Count())
hlViewCart.Text = "View Cart " & dtCount & " Items"
End Sub
When I remove the dtCount the hlViewCart.Text is passed correctly. In other
words it works correctly as long as I dont access the count of the rows of
the datatable stored in the session. I want the view cart link to reflect
the total number of items in the cart "View Cart (3 - Items)"
TIA,
Steve
hyperlink is loaded using the OnLoad = hlViewCart_Load (below) that accesses
a session variable to get the text for the link but, I get the following
error:
Object reference not set to an instance of an object.
Public Sub hlViewCart_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles hlViewCart.Load
Dim sessionCart As DataTable = CType(Session("cart"), DataTable)
Dim dtCount As String = CStr(sessionCart.Rows.Count())
hlViewCart.Text = "View Cart " & dtCount & " Items"
End Sub
When I remove the dtCount the hlViewCart.Text is passed correctly. In other
words it works correctly as long as I dont access the count of the rows of
the datatable stored in the session. I want the view cart link to reflect
the total number of items in the cart "View Cart (3 - Items)"
TIA,
Steve