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 7622657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:30:28+00:00 2026-05-31T04:30:28+00:00

There is a view to update a complex model(Transaction). Complex model has properties which

  • 0

There is a view to update a complex model(Transaction).
Complex model has properties which can have multiple attachments(files),
so that user can upload multiple files simultaneously in this form,
and I am trying to save these files to the database.

I have successfully posted multiple files to the server,
following blog post
http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx.

However in order to save these files, so that I can keep track of which files belongs to which object of the complex model(Transaction) and therefore show them later at appropriate places, I need some way to associate file uploaded to the object it belongs to, but since all files come under name ‘files’ I don’t know how I can make this work.

Here is simplified complex model:

public class Transaction
{
    [Key]
    public int Id { get; set; }

    public virtual PurchaseRequisition PurchaseRequisition { get; set; }

    public virtual Evaluation Evaluation { get; set; }
}

Properties of complex model:

public class PurchaseRequisition
{
    [Key, ForeignKey("Transaction")]
    public int TransactionId { get; set; }

    public virtual Transaction Transaction { get; set; } 

    [Display(Name = "Specifications/Requisitioner's Notes")]
    public virtual ICollection<Attachment> SpecsRequisitionerNotesFiles { get; set; }
}

public class Evaluation
{
    [Key, ForeignKey("Transaction")]
    public int TransactionId { get; set; }

    public virtual Transaction Transaction { get; set; }

    public virtual ICollection<Attachment> BidResultsFiles { get; set; }
}

public abstract class Attachment
{
    [Key]
    public int Id { get; set; }

    public string FileName { get; set; }

    public string FileExtension { get; set; }

    public byte[] Data { get; set; }

    public Boolean Deleted { get; set; }
}

Here is the controller:

[HttpPost]
public ActionResult Create(TransactionViewModel model, IEnumerable<HttpPostedFileBase> files)
{ //save to database }
  • 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-05-31T04:30:30+00:00Added an answer on May 31, 2026 at 4:30 am

    Create separate sections in the view for the purchase requisitions and bid results. Something like this:

    <form action="" method="post" enctype="multipart/form-data">
    
      <h3>Purchase Requistions</h3>
      <label for="file1">Filename:</label>
      <input type="file" name="purchasereqs" id="file1" />
    
      <label for="file2">Filename:</label>
      <input type="file" name="purchasereqs" id="file2" />
    
      <h3>Bid Results</h3>
      <label for="file3">Filename:</label>
      <input type="file" name="bidresults" id="file3" />
    
      <label for="file4">Filename:</label>
      <input type="file" name="bidresults" id="file4" />
    
      <input type="submit"  />
    </form>
    

    Then you would have an action signature like this:

    [HttpPost]
    public ActionResult Create(
      TransactionViewModel model, 
      IEnumerable<HttpPostedFileBase> purchasereqs,
      IEnumerable<HttpPostedFileBase> bidresults)
    { 
       //save to database 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to update a complex model in a single view. I am
I have a 'Complex' model which hasMany Unit. My model associations are correct, everything
I have large batches of XHTML files that are manually updated. During the review
There's no strongly typed View() method to return an ActionResult. So, suppose I have
I am creating a web app which has some complex underlying associations. In order
I have a simple page view tracker that uses a combination of PHP and
I have the following view <ul data-role=listview data-inset=true> <!-- ko with: model.Item_selected --> <li
In my application, I have an NSTableView which should contain a list of files.
I am developing a complex form that updates several records of one model at
I have situation where a publisher application essentially keeps a view model up to

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.