Your button causes a postback and the FileUpload Control lost its
value. To solve this, you could use the UpdatePanel and wrap that
around the controls that are causing the postback.
Actually the FormView is already in an UpdatePanel. Here's the code:
<%@ Page Language="C#" MasterPageFile="~/EMFT.Master" AutoEventWireup="true"
CodeBehind="PublicUpload.aspx.cs" Inherits="EMailFileTransfer.PublicUpload"
Title="EMail File Transfer - Public Upload" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server">
<asp:ScriptManager ID="smUpload" runat="server"/>
<asp:UpdateProgress ID="uprUpload" runat="server"
AssociatedUpdatePanelID="upUpload">
<ProgressTemplate>
File transfer in Progress . . .
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="upUpload" runat="server">
<ContentTemplate>
<table>
</table>
<asp:FormView id="fvTFiles" runat="server"
DataSourceID="dsTFiles" DataKeyNames="biID" DefaultMode="Insert">
<InsertItemTemplate>
<table cellpadding="5">
<tr>
<td>From</td>
<td><asp:TextBox ID="tbFrom" runat="server"
Width="300px"></asp:TextBox></td>
</tr>
<tr>
<td>From EMail (also for confirmation email)</td>
<td><asp:TextBox ID="tbFromEMail" runat="server"
Width="300px"></asp:TextBox></td>
</tr>
<tr>
<td>Send To</td>
<td><asp:DropDownList id="dlSendTo"
runat="server" Width="300px" DataTextField="sName" DataSourceID="dsTUsers"
DataValueField="sUserName" /></td>
</tr>
<tr>
<td>File Title</td>
<td><asp:TextBox id="sFileTitleTextBox"
runat="server" Text='<%# Bind("sFileTitle") %>'></asp:TextBox></td>
</tr>
<tr>
<td>Select File<br />
<asp:RequiredFieldValidator ID="rfvUpload"
runat="server" ControlToValidate="fuUpload"
ErrorMessage="RequiredFieldValidator">You must select a file to
upload.</asp:RequiredFieldValidator></td>
<td><asp:FileUpload id="fuUpload" runat="server"
Width="661px"></asp:FileUpload></td>
</tr>
<tr>
<td><asp:Button id="bUpload" runat="server"
Text="Upload" CausesValidation="true" CommandName="Insert"
OnClick="bUpload_Click"></asp:Button></td>
<td>
</td>
</tr>
</table>
</InsertItemTemplate>
</asp:FormView>
<asp:SqlDataSource id="dsTFiles" runat="server"
ConnectionString="<%$ ConnectionStrings:EMailFileTransferConnectionStrin g %>"
SelectCommandType="StoredProcedure" SelectCommand="spTFilesSelectByUserName"
InsertCommandType="StoredProcedure"
InsertCommand="spTFilesInsertWithUserName" OnInserting="dsTFiles_Inserting"
OnInserted="dsTFiles_Inserted">
<SelectParameters>
<asp:Parameter Type="String" Name="sUserName"
DefaultValue="" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Type="Int64" Direction="InputOutput"
Name="biID"></asp:Parameter>
<asp:Parameter Type="String" Name="sUserName"/>
<asp:Parameter Type="String"
Name="sFileTitle"></asp:Parameter>
<asp:Parameter Type="String"
Name="sFileName"></asp:Parameter>
<asp:Parameter Type="DateTime"
Name="dExpirationDateTime"></asp:Parameter>
<asp:Parameter Type="String" Direction="InputOutput"
Name="sUserEMail"></asp:Parameter>
<asp:Parameter Type="String" Direction="InputOutput"
Name="sPassword"></asp:Parameter>
</InsertParameters>
</asp:SqlDataSource<asp:SqlDataSource id="dsTUsers"
runat="server" ConnectionString="<%$
ConnectionStrings:EMailFileTransferConnectionStrin g %>"
SelectCommandType="StoredProcedure"
SelectCommand="spTUsersSelect"></asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>