Yes thank you, it all makes sense now. There is nothing wrong with the code in the book. I am doing the example in a web form and I thought it wouldn't matter but I'd forgetten about the module level variable so it keeps losing it's value and I get an error. I have solved the problem. For any one else doing it the same way you have to put <Serializable()> before the 'Public Structure Customer' declaration and include the following
vb code on the form:
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Me.ViewState("arrayListInViewState") IsNot Nothing) Then
objCustomers = CType(Me.ViewState("arrayListInViewState"), ArrayList)
End If
End Sub
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
'Save PageArrayList before the page is rendered.
Me.ViewState.Add("arrayListInViewState", objCustomers)
End Sub