title: File upload in FormView (as a parameter)
body: <p>I have FormView in three states: ItemTemplate, EditItemTemplate and InsertItemTemplate.
  In ItemTemaplate, I've made possible to download file from database in a outer manner:</p>
  
  <pre><code>&lt;asp:LinkButton runat="server" OnCommand="GetBenefitPdf" CommandArgument='&lt;%# Eval("benefit_id") %&gt;' Text="Get PDF" /&gt;
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>protected void GetBenefitPdf(object sender, CommandEventArgs e)
  {
      int benefit_id = int.Parse(e.CommandArgument.ToString());
      Response.Redirect("GetPdf.aspx?id=" + benefit_id + "&amp;page=ManageBenefits.aspx");
  }
  </code></pre>
  
  <p>But I also need to upload a file (attachment) in InsertItemTemplate and EditItemTemplate.
  In both of the above I've made:</p>
  
  <pre><code>&lt;asp:FileUpload ID="filedata" runat="server" /&gt;
  </code></pre>
  
  <p>But the SQL commands (parameters are given) are making an exception:</p>
  
  <blockquote>
    <p>String or binary data would be truncated. The statement has been terminated.</p>
  </blockquote>
  
  <p>How should I handle this?</p>
  
  <p>EDIT: SQL is given:</p>
  
  <pre><code>&lt;asp:SqlDataSource ID="SqlDataSourceManageBenefits" runat="server" ConnectionString="&lt;%$ ConnectionStrings:validConnectionString %&gt;"
  SelectCommand="SELECT [min_buyers], [active], [benefit_id], [name], [description], [price], [avail_pcs], [type], [months], [link], [family], [start_date], [end_date], [months_cancel], [price_month], [price_full], [payroll], [payroll_add], [payroll_sub], [price_all], [labor_id], [filedata] FROM [benefits]"
  FilterExpression=" type='{0}' " ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [benefits] WHERE [benefit_id] = @original_benefit_id AND (([min_buyers] = @original_min_buyers) OR ([min_buyers] IS NULL AND @original_min_buyers IS NULL)) AND [active] = @original_active AND (([name] = @original_name) OR ([name] IS NULL AND @original_name IS NULL)) AND (([description] = @original_description) OR ([description] IS NULL AND @original_description IS NULL)) AND (([price] = @original_price) OR ([price] IS NULL AND @original_price IS NULL)) AND (([avail_pcs] = @original_avail_pcs) OR ([avail_pcs] IS NULL AND @original_avail_pcs IS NULL)) AND (([type] = @original_type) OR ([type] IS NULL AND @original_type IS NULL)) AND (([months] = @original_months) OR ([months] IS NULL AND @original_months IS NULL)) AND (([link] = @original_link) OR ([link] IS NULL AND @original_link IS NULL)) AND (([family] = @original_family) OR ([family] IS NULL AND @original_family IS NULL)) AND (([start_date] = @original_start_date) OR ([start_date] IS NULL AND @original_start_date IS NULL)) AND (([end_date] = @original_end_date) OR ([end_date] IS NULL AND @original_end_date IS NULL)) AND (([months_cancel] = @original_months_cancel) OR ([months_cancel] IS NULL AND @original_months_cancel IS NULL)) AND (([price_month] = @original_price_month) OR ([price_month] IS NULL AND @original_price_month IS NULL)) AND (([price_full] = @original_price_full) OR ([price_full] IS NULL AND @original_price_full IS NULL)) AND (([payroll] = @original_payroll) OR ([payroll] IS NULL AND @original_payroll IS NULL)) AND (([payroll_add] = @original_payroll_add) OR ([payroll_add] IS NULL AND @original_payroll_add IS NULL)) AND (([payroll_sub] = @original_payroll_sub) OR ([payroll_sub] IS NULL AND @original_payroll_sub IS NULL)) AND (([price_all] = @original_price_all) OR ([price_all] IS NULL AND @original_price_all IS NULL)) AND (([labor_id] = @original_labor_id) OR ([labor_id] IS NULL AND @original_labor_id IS NULL)) AND (([filedata] = @original_filedata) OR ([filedata] IS NULL AND @original_filedata IS NULL))" InsertCommand="INSERT INTO [benefits] ([min_buyers], [active], [name], [description], [price], [avail_pcs], [type], [months], [link], [family], [start_date], [end_date], [months_cancel], [price_month], [price_full], [payroll], [payroll_add], [payroll_sub], [price_all]), [labor_id], [filedata] VALUES (@min_buyers, @active, @name, @description, @price, @avail_pcs, @type, @months, @link, @family, @start_date, @end_date, @months_cancel, @price_month, @price_full, @payroll, @payroll_add, @payroll_sub, @price_all, @labor_id, @filedata)" OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [benefits] SET [min_buyers] = @min_buyers, [active] = @active, [name] = @name, [description] = @description, [price] = @price, [avail_pcs] = @avail_pcs, [type] = @type, [months] = @months, [link] = @link, [family] = @family, [start_date] = @start_date, [end_date] = @end_date, [months_cancel] = @months_cancel, [price_month] = @price_month, [price_full] = @price_full, [payroll] = @payroll, [payroll_add] = @payroll_add, [payroll_sub] = @payroll_sub, [price_all] = @price_all, [labor_id] = @labor_id, [filedata] = @filedata WHERE [benefit_id] = @original_benefit_id AND (([min_buyers] = @original_min_buyers) OR ([min_buyers] IS NULL AND @original_min_buyers IS NULL)) AND [active] = @original_active AND (([name] = @original_name) OR ([name] IS NULL AND @original_name IS NULL)) AND (([description] = @original_description) OR ([description] IS NULL AND @original_description IS NULL)) AND (([price] = @original_price) OR ([price] IS NULL AND @original_price IS NULL)) AND (([avail_pcs] = @original_avail_pcs) OR ([avail_pcs] IS NULL AND @original_avail_pcs IS NULL)) AND (([type] = @original_type) OR ([type] IS NULL AND @original_type IS NULL)) AND (([months] = @original_months) OR ([months] IS NULL AND @original_months IS NULL)) AND (([link] = @original_link) OR ([link] IS NULL AND @original_link IS NULL)) AND (([family] = @original_family) OR ([family] IS NULL AND @original_family IS NULL)) AND (([start_date] = @original_start_date) OR ([start_date] IS NULL AND @original_start_date IS NULL)) AND (([end_date] = @original_end_date) OR ([end_date] IS NULL AND @original_end_date IS NULL)) AND (([months_cancel] = @original_months_cancel) OR ([months_cancel] IS NULL AND @original_months_cancel IS NULL)) AND (([price_month] = @original_price_month) OR ([price_month] IS NULL AND @original_price_month IS NULL)) AND (([price_full] = @original_price_full) OR ([price_full] IS NULL AND @original_price_full IS NULL)) AND (([payroll] = @original_payroll) OR ([payroll] IS NULL AND @original_payroll IS NULL)) AND (([payroll_add] = @original_payroll_add) OR ([payroll_add] IS NULL AND @original_payroll_add IS NULL)) AND (([payroll_sub] = @original_payroll_sub) OR ([payroll_sub] IS NULL AND @original_payroll_sub IS NULL)) AND (([price_all] = @original_price_all) OR ([price_all] IS NULL AND @original_price_all IS NULL)) AND (([labor_id] = @original_labor_id) OR ([labor_id] IS NULL AND @original_labor_id IS NULL)) AND (([filedata] = @original_filedata) OR ([filedata] IS NULL AND @original_filedata IS NULL))"&gt;
  </code></pre>
  
  <p>Also there are parameters:</p>
  
  <pre><code>&lt;asp:Parameter Name="original_filedata" Type="Byte" /&gt;
  &lt;asp:Parameter Name="filedata" Type="Byte" /&gt;
  </code></pre>