Results 1 to 3 of 3

Thread: Can't retrieve values in Hashtable

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Can't retrieve values in Hashtable

    I am capturing the client path for upload files and storing them in a Hashtable from within the btn_UploadFile event.
    VB Code:
    1. 'i is just a counter
    2. 'Add upload path to hashtable
    3. strUploadPath.Add(attachmentFile.PostedFile.FileName.ToString, i)

    In the btn_Submit click event I am trying to iterate through the Hashtable and grab the key/value pairs, but for some reason it isn't returning anything?? and I don't know why???
    VB Code:
    1. For each de in strUploadPath
    2.    Response.Write("Key: " & de.Key)
    3.    Response.Write("<BR>")
    4.    Response.Write("Value: " & de.Value)
    5. Next

    I don't know why it won't retrieve the values??? I have declared both variables in the General Declarations section, so they should be avaliable to any procedure.

    Dim strUploadPath As New Hashtable
    Dim de As DictionaryEntry

    Does anyone know why I wouldn't be able to retrieve these values from the Hashtable???

    ***EDIT***
    If I have it all in the same sub it works, but I need it separated into 2 different subs.
    Last edited by Memnoch1207; Dec 22nd, 2003 at 05:48 PM.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    Reloading page

    Hi Memnoch.

    As far as I now, when pushing the submit button, the page reloads, thus REdim'ing you variables.

    Try this:

    btn_UploadFile event
    VB Code:
    1. Dim strUploadPath As New Hashtable
    2.  
    3. strUploadPath.Add(attachmentFile.PostedFile.FileName.ToString, i)
    4.  
    5. Session("MyHash")=strUploadPath

    btn_Submit click event
    VB Code:
    1. Dim strUploadPath As Hashtable = Session("MyHash")
    2. Dim de As DictionaryEntry
    3.  
    4. For each de in strUploadPath
    5.    Response.Write("Key: " & de.Key)
    6.    Response.Write("<BR>")
    7.    Response.Write("Value: " & de.Value)
    8. Next

    I have not tested this, but I think it just might work.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  3. #3

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    I figured it out...I need to write the Hashtable values to the ViewState.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

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