Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8862801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:48:57+00:00 2026-06-14T15:48:57+00:00

I have FormView in three states: ItemTemplate, EditItemTemplate and InsertItemTemplate. In ItemTemaplate, I’ve made

  • 0

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:

<asp:LinkButton runat="server" OnCommand="GetBenefitPdf" CommandArgument='<%# Eval("benefit_id") %>' Text="Get PDF" />

and:

protected void GetBenefitPdf(object sender, CommandEventArgs e)
{
    int benefit_id = int.Parse(e.CommandArgument.ToString());
    Response.Redirect("GetPdf.aspx?id=" + benefit_id + "&page=ManageBenefits.aspx");
}

But I also need to upload a file (attachment) in InsertItemTemplate and EditItemTemplate.
In both of the above I’ve made:

<asp:FileUpload ID="filedata" runat="server" />

But the SQL commands (parameters are given) are making an exception:

String or binary data would be truncated. The statement has been terminated.

How should I handle this?

EDIT: SQL is given:

<asp:SqlDataSource ID="SqlDataSourceManageBenefits" runat="server" ConnectionString="<%$ ConnectionStrings:validConnectionString %>"
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))">

Also there are parameters:

<asp:Parameter Name="original_filedata" Type="Byte" />
<asp:Parameter Name="filedata" Type="Byte" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:48:58+00:00Added an answer on June 14, 2026 at 3:48 pm

    Ok, I solved it.
    The solution is to use:

    <asp:Parameter Name="original_filedata" DbType="Binary" />
    <asp:Parameter Name="filedata" DbType="Binary" />
    

    and also make OnInserting and OnUpdating command:

    protected void Attach(object sender, SqlDataSourceCommandEventArgs e)
    {
        var file = ((FileUpload)FormViewManageBenefits.FindControl("filedata")).FileBytes;
        e.Command.Parameters["@filedata"].Value = file;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a FormView from which another user control is launched. The FormView loads
I have a FormView control in an ASP.NET 2.0 app. I've got the database
I have an asp:FormView on a control (in an ascx file) which is loaded
I have an asp:FormView with an ItemTemplate. I'd like to design the content within
On my page I have FormView control, and I am binding Integer database field
I have a FormView control in an ASP.NET page. I use the InsertItemTemplate and
I have a FormView where I pull data from one table (MS Access), and
I have a FormView with paging enabled. The FormView is bound to an EntityDataSource
I have a FormView which I would like to open in insert mode only
I have an asp:FormView control bound to a datasource. Everything is working fine. If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.