I think I'm putting everything in correctly I've read a few other forums that say postback is making it lose the fileUpload capability...
Code:
Protected Sub ListView1_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewInsertEventArgs) Handles ListView1.ItemInserting
Dim FileField As FileUpload = ListView1.FindControl("FileField")
Dim savePath As String = "C:\Inetpub\wwwroot\DotNet_Projects\MyClarkTireResources\Management\Documents\"
If (FileField.HasFile) Then
Dim fileName As String = FileField.FileName
savePath += fileName
FileField.SaveAs(savePath)
Label1.Text = "Your File Was uploaded as " + fileName
Dim virtualFolder As String = "~/Documents/"
Dim physicalFolder As String = Server.MapPath(virtualFolder)
Dim fileNameExt As String = Guid.NewGuid().ToString()
Dim extension As String = System.IO.Path.GetExtension(FileField.FileName)
'Upload(file)
FileField.SaveAs(System.IO.Path.Combine(physicalFolder, fileNameExt + extension))
'Assign url to db:
e.Values("DocumentURL") = virtualFolder + fileNameExt + extension
e.Values("DocumentSize") = 100
e.Values("UploadDate") = DateTime.Now
e.Values("UserName") = Membership.GetUser().UserName
e.Values("DownloadCount") = 0
e.Values("FileType") = "DOC"
Else
Label1.Text = "Trash"
End If
End Sub
Code:
<InsertItemTemplate>
<div id="InfoContainer">
Click Browse to Upload File.<br />
<asp:FileUpload ID="FileField" runat="server" size="60" /><br />
</div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
Title:
<asp:TextBox ID="FileNameTextBox" runat="server" Text='<%# Bind("Title") %>' /><br />
Description:
<asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</InsertItemTemplate>
Error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 68: 'Dim UploadDetails As Label
Line 69:
Line 70: FileName.InnerHtml = FileField.PostedFile.FileName <==HERE IS WHERE IT IS RED ################
Line 71: FileContent.InnerHtml = FileField.PostedFile.ContentType
Line 72: FileSize.InnerHtml = FileField.PostedFile.ContentLength