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. General Programming
  3. C#
  4. Collections

Collections

Scheduled Pinned Locked Moved C#
csharpasp-netquestion
6 Posts 3 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.
  • G Offline
    G Offline
    gordingin
    wrote on last edited by
    #1

    Is CObArray and CObList the equivalent of a collection under .NET? I want pass data from one form to the other and then into a control. Can I create a class, add them to the collection, pass it and then fill the control? This in in ASP.NET btw... Thanks Ralph

    H 1 Reply Last reply
    0
    • G gordingin

      Is CObArray and CObList the equivalent of a collection under .NET? I want pass data from one form to the other and then into a control. Can I create a class, add them to the collection, pass it and then fill the control? This in in ASP.NET btw... Thanks Ralph

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      ASP.NET is really no different from CGI in the world of HTTP. You can't really send a collection from form to form - you need to use POST data just like form elements in a page. You could store the collection in a session variable, but you'll take big performance hits if you don't clean it up correctly. I'm not really sure what those objects are, but they appear to be an array and a list. Lists are those classes that implement IList (and inherit ICollection and IEnumerable). Arrays implicitly derive from System.Array, which implements IList. So, they're both lists (but you can't use some methods from the aforementioned interfaces with an array - it's still a fixed number of elements). You could serialize this collection and base64-encode it, then make sure it gets sent with your form data to the next page, deserializing it. If you're remaining on the same page (i.e., using post-back), you could also extend the Page class (your .aspx and code-behind files do this already) and override SaveViewState and LoadViewState to save this serialized collection, but this only works if using post-back with the same page. You should definitely read the documentation on those two methods - implementing them can be tricky, especially if you don't know what you're doing.

      Microsoft MVP, Visual C# My Articles

      G 1 Reply Last reply
      0
      • H Heath Stewart

        ASP.NET is really no different from CGI in the world of HTTP. You can't really send a collection from form to form - you need to use POST data just like form elements in a page. You could store the collection in a session variable, but you'll take big performance hits if you don't clean it up correctly. I'm not really sure what those objects are, but they appear to be an array and a list. Lists are those classes that implement IList (and inherit ICollection and IEnumerable). Arrays implicitly derive from System.Array, which implements IList. So, they're both lists (but you can't use some methods from the aforementioned interfaces with an array - it's still a fixed number of elements). You could serialize this collection and base64-encode it, then make sure it gets sent with your form data to the next page, deserializing it. If you're remaining on the same page (i.e., using post-back), you could also extend the Page class (your .aspx and code-behind files do this already) and override SaveViewState and LoadViewState to save this serialized collection, but this only works if using post-back with the same page. You should definitely read the documentation on those two methods - implementing them can be tricky, especially if you don't know what you're doing.

        Microsoft MVP, Visual C# My Articles

        G Offline
        G Offline
        Guillermo Rivero
        wrote on last edited by
        #3

        The only way to pass data between forms is using Session, isn't it ? Free your mind...

        H 1 Reply Last reply
        0
        • G Guillermo Rivero

          The only way to pass data between forms is using Session, isn't it ? Free your mind...

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          No, it's not the only way. Any data defined as an input for the page form can be sent to another page, which can retrieve it using Request.Forms (POST), Request.QueryString (GET), or Request.Params (both). How do you think CGI has worked since it was proposed? This data doesn't have to be input by the user - it can simply be in a hidden input field. The developer just has to make sure it gets in there before the GET or POST request is sent to another page (since that data is sent from the client to the new page).

          Microsoft MVP, Visual C# My Articles

          G 1 Reply Last reply
          0
          • H Heath Stewart

            No, it's not the only way. Any data defined as an input for the page form can be sent to another page, which can retrieve it using Request.Forms (POST), Request.QueryString (GET), or Request.Params (both). How do you think CGI has worked since it was proposed? This data doesn't have to be input by the user - it can simply be in a hidden input field. The developer just has to make sure it gets in there before the GET or POST request is sent to another page (since that data is sent from the client to the new page).

            Microsoft MVP, Visual C# My Articles

            G Offline
            G Offline
            Guillermo Rivero
            wrote on last edited by
            #5

            I know that this is not the only way to share info between forms. I've done some ASP and CGI. I didn't explain myself with the question... I meant, is that the only way to do it using ASP.NET ? Free your mind...

            H 1 Reply Last reply
            0
            • G Guillermo Rivero

              I know that this is not the only way to share info between forms. I've done some ASP and CGI. I didn't explain myself with the question... I meant, is that the only way to do it using ASP.NET ? Free your mind...

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              Well, besides sessions and and form data (thus meaning that sessions still aren't the only way in ASP.NET), you could always store it in a repository of sorts, like a database, file (bad!), cookie, etc. The nice thing about using a session is that the original poster wouldn't have to serialize the collection and could just store it in the session as-is. Sessions can be very nice, but they are often over-used (especially when large amounts of data are stored in them). As I mentioned before, too, if you use post-back and stay on the same page (seems to be most common with ASP.NET), you can use the ViewState but the page implementation is responsible for saving and loading that ViewState (and one must be careful when doing so).

              Microsoft MVP, Visual C# My Articles

              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