Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Custom object Collections and ViewState

Custom object Collections and ViewState

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Spursoft
    wrote on last edited by
    #1

    Does anyone know of an example or have some sample code for saving a Class object derived from CollectionBase containing Custom Class objects? Derek Spurlock Spursoft Solutions

    E 1 Reply Last reply
    0
    • S Spursoft

      Does anyone know of an example or have some sample code for saving a Class object derived from CollectionBase containing Custom Class objects? Derek Spurlock Spursoft Solutions

      E Offline
      E Offline
      eidylon
      wrote on last edited by
      #2

      Hi, I dont know if this is unworkable for you or not, but here is how i addressed this problem. I thought about making my class so it would support serialization and all to be easily savable to the viewstate, but then i realized... if you serialize you collection out to the viewstate, then with each transmission back and forth, the page will be retransmitting the whole collection of data. So instead, i stuck my collection in a session variable. Then, to make it easy to access i created a property on my pages so they could just reference Me.MfgList which would return the list. So here is my code in abbreviated form: Public Class AppPageBase Inherits System.Web.UI.Page    Protected Readonly Property MfgList As clsMfgList     Get       Return CType(Session("mfglist"),clsMfgList)     End Get   End Property End Class Then all my pages inherit from AppPageBase instead of from System.Web.UI.Page directly. You can load your list into the session variable in the Session_OnStart event in global.asax. This same method is a great way to provide easy access to lots of other app-specific custom data.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups