title: File Upload control HasFile always false, name is always Empty String, no update panel used
body: <p>I have a Details View that has a file upload field in it.  When I fill out the information and upload a file (I have tried multiple files ranging from 9k to 6.8MB) all of the information (text fields) submit fine, but the uploaded file is always returning a false when I check the HasFile and always returns String.Empty when I check the file name.</p>
  
  <p>Am I doing something wrong?  The details view is in a Panel and <strong>Not an Update Panel</strong></p>
  
  <pre><code>    &lt;asp:Panel ID="pnlUpdate" runat="server"
          Visible="false"&gt;
          &lt;h4 runat="server" id="h2SubCaption"&gt;Person Details&lt;/h4&gt;
          &lt;asp:DetailsView ID="dvAssignment" 
              runat="server" 
              AutoGenerateRows="false" 
              Width="100%"
              SkinID="SampleDetailsView" 
              CssSelectorClass="PrettyDetailsView"
              DataKeyNames="guidMemberId"
              DefaultMode="Edit"
              OnItemUpdating="dvAssignment_ItemUpdating" 
              OnModeChanging="dvAssignment_ModeChanging"
              AutoGenerateEditButton="True" &gt;  
  &lt;Fields&gt;   
  &lt;asp:TemplateField HeaderText="Nomination Letter"&gt;
                          &lt;EditItemTemplate&gt;
                              &lt;asp:FileUpload runat="server" ID="fileuploadNomination" /&gt;
                          &lt;/EditItemTemplate&gt;
                      &lt;/asp:TemplateField&gt; .....
  </code></pre>
  
  <p>Code Behind:</p>
  
  <pre><code>        FileUpload _nomination = (FileUpload)dv.FindControl("fileuploadNomination");
      byte[] nominationByte = null;
      if (_nomination.FileName != string.Empty)
          nominationByte = _nomination.FileBytes;
      //if(_nomination.HasFile)
      //nominationByte = _nomination.FileBytes;
  </code></pre>
  
  <p><strong>EDIT</strong>
  I added a Page_Load call and it looks as if the page is posting back when I click the Auto Generated Update Button for the DetailsView.  This postback is probably clearing out my FileUpload field.  Any ideas on how to get around it?</p>
  
  <p><strong>Edit #2</strong> I have now put an update panel around the DetailsView and set the postback trigger the DetailsView (see below) and it still is not working, it seems to be clearing the upload control prior to submitting.</p>
  
  <pre><code>&lt;asp:UpdatePanel ID="updatePnl" runat="server" UpdateMode="Conditional"&gt;
      &lt;ContentTemplate&gt;
          &lt;asp:Panel ID="pnlUpdate" runat="server"
              Visible="false"&gt;
              &lt;h4 runat="server" id="h2SubCaption"&gt;Person Details&lt;/h4&gt;
              &lt;asp:DetailsView ID="dvAssignment" 
                  runat="server" 
                  AutoGenerateRows="false" 
                  Width="100%"
                  SkinID="SampleDetailsView" 
                  CssSelectorClass="PrettyDetailsView"
                  DataKeyNames="guidMemberId"
                  DefaultMode="Edit"
                  OnItemUpdating="dvAssignment_ItemUpdating" 
                  OnModeChanging="dvAssignment_ModeChanging"
                  AutoGenerateEditButton="True" &gt;
                  &lt;FieldHeaderStyle Font-Bold="True" Width="150px" /&gt;
                  &lt;Fields&gt;
  </code></pre>
  
  <p>
                              </p>
  
  <pre><code>                            &lt;asp:FileUpload runat="server" ID="fileuploadNomination" /&gt;
                          &lt;/EditItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
   &lt;/Fields&gt;
                  &lt;/asp:DetailsView &gt;       
              &lt;/asp:Panel&gt;
           &lt;/ContentTemplate&gt;
          &lt;Triggers&gt;
              &lt;asp:PostBackTrigger ControlID="dvAssignment" /&gt; 
          &lt;/Triggers&gt;
      &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p><strong>Gridview Code as requested</strong></p>
  
  <pre><code> &lt;asp:GridView ID="gvQuality" 
          runat="server" 
          AutoGenerateColumns="False"
          Width="100%"
          DataKeyNames="guidMemberId"
          CssSelectorClass="PrettyGridView"
          SkinID="SampleGridView"
          OnSelectedIndexChanged="gvQuality_SelectedIndexChanged" 
          onrowdatabound="gvQuality_RowDataBound"&gt;
          &lt;Columns&gt;
              &lt;asp:TemplateField&gt;
                  &lt;ItemTemplate&gt;
                     &lt;asp:LinkButton ID="btnViewDetails" runat="server" Text="Edit" CommandName="Select" /&gt;
                                      &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>a few bound fields are after this (first name, last name, etc)</p>
  
  <pre><code>protected void gvQuality_SelectedIndexChanged(object sender, EventArgs e)
  {
      Guid guidMemberId = (Guid)gvQuality.SelectedDataKey.Values["guidMemberId"];
      PortalDataContext db = new PortalDataContext(AuthenticatedUser.ConnectionString);
      h2SubCaption.InnerText = "Update Person";
      dvAssignment.ChangeMode(DetailsViewMode.Edit);
  
      dvAssignment.DataSource = LINQ Query Here
      dvAssignment.DataBind();
  }
  </code></pre>