I have another issue..


I have created a DataTable object in a first page into a dataset and into a Session variable. I have filled this table with data from a form in that page, and runs fine. Now on the next page I want to store more data in the same DataTable and Session. I have writed the code on the next page in order to do this, but when I load the page and I trigger the subroutine nothing is stored into the table (the new columns with its new values-row) in the current session. I don' t understand why, the code on the second page is thus:
Code:
Sub myData(Sender As Object, e As EventArgs)
   
   Dim ds As DataSet
   ds = CType(Session("UserData"), DataSet)
   
   ds.Tables(0).columns.add("newColumn1")
   ds.Tables(0).columns.add("newColumn2") 
   ...  
 
   Dim row As DataRow
   row = ds.Tables(0).NewRow
   row.Item("newcolumn1") = control1.Text
   row.Item("newColumn2") = control2.SelectedItem.Value
   ...
   
   ds.Tables(0).Rows.Add(row)
 
End Sub
When I try to show one of this new fields created on the next page thus:

Code:
    Dim UserDS As Data.DataSet = Session("UserData") 
    control.Text = UserDS.Tables(0).rows(0).Item("newColumn1")
an error message appears saying:
System.InvalidCastException: Cast from type 'DBNull' to type 'String' is not valid.
Line 108: control.Text = UserDS.Tables(0).rows(0).Item(“newColumn1")

And I entered text in the ‘control1’ text field.
Somebody knows what it lacks?


Thanks