Results 1 to 6 of 6

Thread: Adding DataRow to view state...little problem.

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Adding DataRow to view state...little problem.

    I have a stongly typed Dataset. From this a get a new strongly typed datarow.
    I want to add this to my viewstate.

    But I get the following error:

    Woof
    Attached Images Attached Images  

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Adding DataRow to view state...little problem.

    Odd... the datarow class is marked serializable.

    What I think, is that the datarow either contains a nonserializable member, or contains a reference to something we haven't considered yet.

    I think you should add the entire datatable/dataset to viewstate.

  3. #3

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Adding DataRow to view state...little problem.

    VB Code:
    1. <Serializable(),  _
    2.  System.ComponentModel.DesignerCategoryAttribute("code"),  _
    3.  System.Diagnostics.DebuggerStepThrough(),  _
    4.  System.ComponentModel.ToolboxItem(true)>  _
    5. Public Class dsBooking
    6.     Inherits DataSet
    7.    
    8.     Private tableBookingDetail As BookingDetailDataTable
    9.    
    10.     Public Sub New()
    11.         MyBase.New
    12.         Me.InitClass
    13.         Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
    14.         AddHandler Me.Tables.CollectionChanged, schemaChangedHandler
    15.         AddHandler Me.Relations.CollectionChanged, schemaChangedHandler
    16.     End Sub
    17.  
    18.    'Blah blah blah
    19.  
    20.    <System.Diagnostics.DebuggerStepThrough()>  _
    21.     Public Class BookingDetailRow
    22.         Inherits DataRow
    23.        
    24.         Private tableBookingDetail As BookingDetailDataTable
    25.        
    26.         Friend Sub New(ByVal rb As DataRowBuilder)
    27.             MyBase.New(rb)
    28.             Me.tableBookingDetail = CType(Me.Table,BookingDetailDataTable)
    29.         End Sub
    30.  
    31.         'blah blah blah
    32.  
    33.     End Class
    34.  
    35. End Class
    This strongly typed DataRow is declared, Public Class bit, inside the strongly typed dataset.
    As you can see the DataSet is Serializable, but the DataRow doesn't have this.

    I cannot stopre the entire dataset as a function I have only returns a strongly typed datarow:
    VB Code:
    1. Public Function FetchBookingToEdit(ByVal BookingKey As Integer) As Booking.BookingDetailRow
    2.         Dim SQL As String = EditSQL
    3.  
    4.         SQL &= "WHERE BookingKey = @BookingKey "
    5.  
    6.         Dim Comm As New Mowlem.Data.DataLib.Command(SQL)
    7.  
    8.         Comm.Parameters.Add("@BookingKey", BookingKey)
    9.  
    10.         Dim dt As New Booking
    11.  
    12.         MyBase.DataLib.FillDataTable(Comm, dt.BookingDetail)
    13.  
    14.         If dt.BookingDetail.Rows.Count = 1 Then
    15.             Return dt.BookingDetail.Item(0)
    16.         End If
    17.     End Function
    Where the booking class, Dim dt As New Booking, inherits my strongly typed dataset.

    Woof

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Adding DataRow to view state...little problem.

    Did you try making it serializable? Or add it to the session object(?)

  5. #5

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Adding DataRow to view state...little problem.

    Still doesn't work if I make it serializable
    Session state...hmmmm...can't tell when a user closes down the popup window and therefore the objct will stay in the session collection. gonna reload the object of Page_load me thinks.

    Booooo

    woof

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Adding DataRow to view state...little problem.

    Just a hunch, but when you're making it serializable, mark all your methods and properties as nonserializable.

    Does it work after that?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width