0

我正在部署一个 Adventure Cycle 页面,人们可以在其中订购一辆自行车。我想创建一个Shipping Information包含(地址 1、地址 2、城市、国家/地区、邮编/邮政和州/省)。当点击Submit Order它会重定向到Complete页面,通知User订单成功。

Address模型:

public partial class Address
    {
        public Address()
        {
            this.SalesOrderHeaders = new HashSet<SalesOrderHeader>();
            this.SalesOrderHeaders1 = new HashSet<SalesOrderHeader>();
        }

        public int AddressID { get; set; }
        public string AddressLine1 { get; set; }
        public string AddressLine2 { get; set; }
        public string City { get; set; }
        public Nullable<int> StateProvinceID { get; set; }
        public string PostalCode { get; set; }
        public System.Guid rowguid { get; set; }

        public Nullable<System.DateTime> ModifiedDate { get; set; }

        public virtual StateProvince StateProvince { get; set; }
        public virtual ICollection<SalesOrderHeader> SalesOrderHeaders { get; set; }
        public virtual ICollection<SalesOrderHeader> SalesOrderHeaders1 { get; set; }
    }

Sales Order Header

public partial class SalesOrderHeader
    {
        public SalesOrderHeader()
        {
            this.SalesOrderDetails = new HashSet<SalesOrderDetail>();
        }

        public int SalesOrderID { get; set; }

        public byte RevisionNumber { get; set; }


        public Nullable<System.DateTime> OrderDate { get; set; }

        public Nullable<System.DateTime> DueDate { get; set; }

        public Nullable<System.DateTime> ShipDate { get; set; }
        public byte Status { get; set; }

        public bool OnlineOrderFlag { get; set; }
        public string SalesOrderNumber { get; set; }
        public string PurchaseOrderNumber { get; set; }
        public string AccountNumber { get; set; }
        public int CustomerID { get; set; }
        public Nullable<int> SalesPersonID { get; set; }
        public Nullable<int> TerritoryID { get; set; }
        public Nullable<int> BillToAddressID { get; set; }
        public Nullable<int> ShipToAddressID { get; set; }
        public int ShipMethodID { get; set; }
        public Nullable<int> CreditCardID { get; set; }

有人对此有什么建议吗?谢谢你的时间!

4

1 回答 1

1

希望对您有所帮助,在您的完整视图中,您必须将模型地址放入完整表单的重定向方法中:喜欢

`Public ActionResult SubmitOrder(Address address)
   { 
       ...
       return View("Complete", address);
   }
 ` 
and 
on your Complete View
first line must be
`
@Model namespace.Model.Address

//then you can use
  @model.AddressLine1 
  @model.AddressLine2
  @model.City
  @model.PostalCode 
  @model.StateProvinceID // You will retrieve an Id here I guess but at least you will 
                         //have your data. embedded in your razor code  

`

于 2014-03-14T08:37:23.053 回答