0

there, I want to post Purchase record to controller, My Model contain the following two classes, named Purchase and PurchaseDetails

    public partial class Purchase
{
    public Purchase()
    {
        this.PurchaseDetails = new HashSet<PurchaseDetail>();
    }

    public int purchaseId { get; set; }
    public System.DateTime purchaseDate { get; set; }
    public int vendorCode { get; set; }
    public string vendorName { get; set; }
    public int purVoucherNo { get; set; }

    public virtual ICollection<PurchaseDetail> PurchaseDetails { get; set; }
}

public partial class PurchaseDetail
{
    public int code { get; set; }
    public int purchaseDetailsId { get; set; }
    public string serialNo { get; set; }
    public int productCode { get; set; }
    public string productName { get; set; }
    public string unitOfMeasure { get; set; }
    public int quantity { get; set; }
    public decimal purchasePrice { get; set; }
    public decimal amount { get; set; }

    public virtual Purchase Purchase { get; set; }
}

Now, First i want to dynamically store and show purchase detail data in a table and secondly i want to pass one object of Purchase and More than one objects of PurchaseDetails to Controller. Please Help me. I don't know how to Accomplish this task.

  • Refer also [this answer](https://stackoverflow.com/questions/40539321/a-partial-view-passing-a-collection-using-the-html-begincollectionitem-helper/40541892#40541892) for a more detailed example using `BeginCollectionItem` –  Aug 24 '17 at 06:36
  • Can u please explain further, any detailed example matching with my scenario. i didn't want to use partial view – hafiz siddiq Aug 25 '17 at 18:00
  • I am also not using partial views. i want to do this without involving partial views. – hafiz siddiq Aug 26 '17 at 06:16
  • Then read the dupe - the 2nd option! But as an obvious beginner in MVC, I very strongly you use the `BeginCollectionItem` method –  Aug 26 '17 at 06:19

0 Answers0