D
David Kenneally
Hello-
I'm having a problem doing a file upload from within the edit function
of a datalist. I have a simple file upload that works on a standard
..net page:
<td width="53"><input id="inpFileUp" type="file" runat="Server"
/> </td>
<asp:Button id="Button1" onclick="Button_Click2" Runat="Server"
Text="Upload File!"></asp:Button>
And this is the function to upload the file:
Sub Button_Click2( s As Object, e As EventArgs )
Dim fileName As String
Dim saveAs As String
Dim resultsText as String
fileName = inpFileUp.PostedFile.FileName
fileName = Path.GetFileName(fileName)
saveAs = "C:\inetpub\wwwroot\images\" & fileName
inpFileUp.PostedFile.SaveAs( saveAs )
resultsText = "Image file: "
lblUploadResults.Text = resultsText
lblUploadFile.Text = fileName
inpFileUp.Visible=False
Button1.Visible=False
End Sub
This all works fine. It doesn't, of course, work from within the edit
item template of a datalist. I get this error:
"Name 'inpFileUp' is not declared"
I can't seem to use "find control" either, sense I'm calling it from a
button click.
If I try to skip the actual upload until I'm in the "update item"
function, I get errors such as :
System.Web.UI.Control cannot be converted to System.Web.HttpPostedFile
So anyhow, the idea is that I have a datalist with a number of
records, and I'd like to be able to upload a file from within the edit
item template of one of these items.
Any ideas?
Thank you!
David
I'm having a problem doing a file upload from within the edit function
of a datalist. I have a simple file upload that works on a standard
..net page:
<td width="53"><input id="inpFileUp" type="file" runat="Server"
/> </td>
<asp:Button id="Button1" onclick="Button_Click2" Runat="Server"
Text="Upload File!"></asp:Button>
And this is the function to upload the file:
Sub Button_Click2( s As Object, e As EventArgs )
Dim fileName As String
Dim saveAs As String
Dim resultsText as String
fileName = inpFileUp.PostedFile.FileName
fileName = Path.GetFileName(fileName)
saveAs = "C:\inetpub\wwwroot\images\" & fileName
inpFileUp.PostedFile.SaveAs( saveAs )
resultsText = "Image file: "
lblUploadResults.Text = resultsText
lblUploadFile.Text = fileName
inpFileUp.Visible=False
Button1.Visible=False
End Sub
This all works fine. It doesn't, of course, work from within the edit
item template of a datalist. I get this error:
"Name 'inpFileUp' is not declared"
I can't seem to use "find control" either, sense I'm calling it from a
button click.
If I try to skip the actual upload until I'm in the "update item"
function, I get errors such as :
System.Web.UI.Control cannot be converted to System.Web.HttpPostedFile
So anyhow, the idea is that I have a datalist with a number of
records, and I'd like to be able to upload a file from within the edit
item template of one of these items.
Any ideas?
Thank you!
David