Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

//homopterous64.rssing.com/chan-54021951/article6097-live.html

$
0
0

Added a MVC Controller view using Entity Framework

In the orders Model I have 

[Required]
[Display(Name = "Action Type", Description = "Action Type.", Prompt = "Action Type", ShortName = "Action", Order = 10)]
public int ActionID { get; set; }

[Required]
[Display(Name = "Transaction Type", Description = "Transaction Type.", Prompt = "Transaction Type", ShortName = "Transaction", Order = 11)]
public int TransactionID { get; set; }

public ActionType ActionType { get; set; }
public TransactionType TransactionType { get; set; }

------------------------------------------------------------------

ActionType Model

[Key]
[ScaffoldColumn(false)]
public int ID { get; set; }

[MaxLength(32)]
[Required(AllowEmptyStrings = false, ErrorMessage = "Action Type is Required.")]
[Display(Name = "Action", Description = "The Action Type.", Prompt = "Action Type", ShortName = "Action", Order = 1)]
public string Action { get; set; }

public ICollection<Order> Orders { get; set; }

---------------------------------------------------------------------------

TransactionType Model

[Key]
[ScaffoldColumn(false)]
public int ID { get; set; }

[MaxLength(32)]
[Required(AllowEmptyStrings = false, ErrorMessage = "Transaction Type is Required.")]
[Display(Name = "Transaction", Description = "The Transaction Type.", Prompt = "Transaction Type", ShortName = "Transaction", Order = 1)]
public string Type { get; set; }

public ICollection<Order> Orders { get; set; }

---------------------------------------------------------------------------

In Create.cshtml I want to change these to a list of ActionType and TransactionType but this is generated:

<div class="form-group">
<label asp-for="ActionID" class="control-label"></label>
<input asp-for="ActionID" class="form-control" />
<span asp-validation-for="ActionID" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="TransactionID" class="control-label"></label>
<input asp-for="TransactionID" class="for-control"/>
<span asp-validation-for="TransactionID" class="text-danger"></span>
</div>

The Controller Create has no model

// GET: Trade/Orders/Create
public IActionResult CreateAsync()
{

return View();
}

and the Create.cshtml as no @model IEnumerable

@model Data_Store.Trading.Order

So what is the correct way to do this so I have 2 dropdown select lists.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>