|
-
Dec 22nd, 2003, 05:38 PM
#1
Thread Starter
Frenzied Member
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:
'i is just a counter
'Add upload path to hashtable
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:
For each de in strUploadPath
Response.Write("Key: " & de.Key)
Response.Write("<BR>")
Response.Write("Value: " & de.Value)
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
-
Dec 22nd, 2003, 06:04 PM
#2
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:
Dim strUploadPath As New Hashtable
strUploadPath.Add(attachmentFile.PostedFile.FileName.ToString, i)
Session("MyHash")=strUploadPath
btn_Submit click event
VB Code:
Dim strUploadPath As Hashtable = Session("MyHash")
Dim de As DictionaryEntry
For each de in strUploadPath
Response.Write("Key: " & de.Key)
Response.Write("<BR>")
Response.Write("Value: " & de.Value)
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...
-
Dec 22nd, 2003, 06:07 PM
#3
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|