MVC Core Trying to fill a table row by selecting first column












0














I'm very new to programming and I got really confused how to do this..



What I'm trying to do is a table for creating an offer after picking the materials I want. Price will change while I pick different materials. At the end, I will save the offer, with total price etc.



I have a list of Product Models. And in my view, I would like to pick the product model I want in "First Column" using it's FullName and I want to populate other columns in same row with the Models' predefined details that I just picked.



I made a research how to do it. Jquery, Ajax were mentioned but I will have to add more of those dropdown lists with more Viewbags. Don't I have to write a new Ajax for each dropdown then ?



I really hope to be guided in what way I should try to do this.



Thanks in advance!



 public class Model:BaseEntity
{
public TypeOfPart TypeOfPart { get; set; }
public string BrandName { get; set; }
public string ModelName { get; set; }
public string VersionName { get; set; }
public decimal? ListPriceTL { get; set; }
public decimal? ListPriceForeign { get; set; }
public ForeignCurrency? ForeignCurrency { get; set; }
public decimal CurrentDiscount { get; set; } = 0.00M;

public int? CertificateId { get; set; }
public Certificate Certificate { get; set; }

public string FullName => $"{BrandName} {ModelName} {VersionName}";


My Controller



public IActionResult Create()
{
int amountOfElevators = Convert.ToInt32(TempData["Amount"]);
ViewBag.amount = amountOfElevators;


ViewData["Machines"] = new SelectList(_context.ModelRepo.GetAll()
.Where(x => x.TypeOfPart
==TypeOfPart.Machine),"Id","FullName");



ViewData["ConstructionCompanyId"] = new
SelectList(_context.ConstructionCompanyRepo.GetAll(), "Id", "Name","Id");
ViewData["EmployeeId"] = new
SelectList(_context.EmployeeRepo.GetAll(), "Id", "FullName");
return View();
}


Here's the image for a little more description of what I need



EDIT:
My View Model



public class InstallationOfferVM
{
public InstallationOfferVM()
{
OfferedElevators = new List<OfferedElevator>();
Models = new List<Model>();
}
public int Id { get; set; }
[Display(Name = "Toplam ₺")]
public decimal TotalPriceTL { get; set; }
[Display(Name = "Toplam €")]
public decimal TotalPriceEuro { get; set; }
[Display(Name = "Açıklama")]
public string Description { get; set; }
[Display(Name = "Müşteri Firma")]
public int ConstructionCompanyId { get; set; }
[Display(Name = "Müşteri Firma")]
public string CompanyName { get; set; }
public ConstructionCompany ConstructionCompany { get; set; }
[Display(Name = "Teklif Tarihi")]
[DataType(DataType.Date)]
public DateTime DateOfProposal { get; set; }
[Display(Name = "Teklifi Veren")]
public int EmployeeId { get; set; }
[Display(Name = "Teklifi Veren")]
public string EmployeeFullName { get; set; }
public Employee Employee { get; set; }
[Display(Name = "Teklif Durumu")]
public ProposalStatus ProposalStatus { get; set; }
[Display(Name = "İletme Şekli")]
public DeliveredBy DeliveredBy { get; set; }
[Display(Name = "Asansör Adedi")]
public int AmountOfElevators { get; set; }


public List<OfferedElevator> OfferedElevators { get; set; }
public OfferedElevator OfferedElevator { get; set; }


public int InstallationOfferId { get; set; }
[Display(Name = "Kapasite")]
public int Capacity { get; set; }
[Display(Name = "Durak")]
public int StopCount { get; set; }
[Display(Name = "Halat Adedi")]
public int MachineRopeCount { get; set; }
[Display(Name = "Askı Tipi")]
public int HangStyle { get; set; } = 1;
[Display(Name = "Tahrik Tipi")]
public DriveType DriveType { get; set; }
[Display(Name = "Ortalama Kat Yüksekliği")]
public decimal AvgFloorHeight { get; set; } = 3.00M;
[Display(Name = "Giriş Adedi")]
public int EntranceCount { get; set; } = 1;
[Display(Name = "Ekstra Kapı")]
public int AdditionalDoor { get; set; } = 1;
[Display(Name = "Ağırlık Yanda İse")]
public bool WeightInSide { get; set; }
[Display(Name = "Kapı Yüksekliği 2100 ise")]
public bool DoorHeightIs2100 { get; set; } = false;
[Display(Name = "Euro Kuru")]
public decimal CurrentEuro { get; set; }
public List<Model> Models { get; set; }
public Model Model { get; set; }
}


My View



@model Ace.ViewModels.InstallationOfferVM
@for (int i = 0; i < ViewBag.amount; i++)
{
<table class="table-sm table-striped table-dark col-md-9">
<thead>
<tr>
<th></th>
<th>Malzeme Cinsi</th>
<th>Adet</th>
<th>Liste Euro</th>
<th>Liste TL</th>
<th>İskonto</th>
<th>Toplam</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td><select asp-for="Model.Id" class="form-control" asp-
items="ViewBag.Machines"></select></td>
<td>1</td>
<td></td>
</tr>
</tbody>
</table>
</div>
<hr />
}
</form>
<div>
<a asp-action="Index">Back to List</a>
</div>









share|improve this question
























  • do not use Viewdata to pass model to view. you can pass model to view. some limiation of viewdata is stackoverflow.com/questions/15567891/….
    – Kiran Joshi
    Nov 20 '18 at 12:44












  • Could you demonstrate your View (.cshtml) file?
    – Alexander I.
    Nov 20 '18 at 12:45










  • I've noticed that I shouldn't use Viewdata to pass model to view. But I'm quite unsure how to achieve my goal so I was trying everything :)
    – Pumpkin
    Nov 20 '18 at 13:04










  • To pass the viewmodel to your view, just do return View(viewmodel);
    – ramon abacherli
    Nov 20 '18 at 13:28
















0














I'm very new to programming and I got really confused how to do this..



What I'm trying to do is a table for creating an offer after picking the materials I want. Price will change while I pick different materials. At the end, I will save the offer, with total price etc.



I have a list of Product Models. And in my view, I would like to pick the product model I want in "First Column" using it's FullName and I want to populate other columns in same row with the Models' predefined details that I just picked.



I made a research how to do it. Jquery, Ajax were mentioned but I will have to add more of those dropdown lists with more Viewbags. Don't I have to write a new Ajax for each dropdown then ?



I really hope to be guided in what way I should try to do this.



Thanks in advance!



 public class Model:BaseEntity
{
public TypeOfPart TypeOfPart { get; set; }
public string BrandName { get; set; }
public string ModelName { get; set; }
public string VersionName { get; set; }
public decimal? ListPriceTL { get; set; }
public decimal? ListPriceForeign { get; set; }
public ForeignCurrency? ForeignCurrency { get; set; }
public decimal CurrentDiscount { get; set; } = 0.00M;

public int? CertificateId { get; set; }
public Certificate Certificate { get; set; }

public string FullName => $"{BrandName} {ModelName} {VersionName}";


My Controller



public IActionResult Create()
{
int amountOfElevators = Convert.ToInt32(TempData["Amount"]);
ViewBag.amount = amountOfElevators;


ViewData["Machines"] = new SelectList(_context.ModelRepo.GetAll()
.Where(x => x.TypeOfPart
==TypeOfPart.Machine),"Id","FullName");



ViewData["ConstructionCompanyId"] = new
SelectList(_context.ConstructionCompanyRepo.GetAll(), "Id", "Name","Id");
ViewData["EmployeeId"] = new
SelectList(_context.EmployeeRepo.GetAll(), "Id", "FullName");
return View();
}


Here's the image for a little more description of what I need



EDIT:
My View Model



public class InstallationOfferVM
{
public InstallationOfferVM()
{
OfferedElevators = new List<OfferedElevator>();
Models = new List<Model>();
}
public int Id { get; set; }
[Display(Name = "Toplam ₺")]
public decimal TotalPriceTL { get; set; }
[Display(Name = "Toplam €")]
public decimal TotalPriceEuro { get; set; }
[Display(Name = "Açıklama")]
public string Description { get; set; }
[Display(Name = "Müşteri Firma")]
public int ConstructionCompanyId { get; set; }
[Display(Name = "Müşteri Firma")]
public string CompanyName { get; set; }
public ConstructionCompany ConstructionCompany { get; set; }
[Display(Name = "Teklif Tarihi")]
[DataType(DataType.Date)]
public DateTime DateOfProposal { get; set; }
[Display(Name = "Teklifi Veren")]
public int EmployeeId { get; set; }
[Display(Name = "Teklifi Veren")]
public string EmployeeFullName { get; set; }
public Employee Employee { get; set; }
[Display(Name = "Teklif Durumu")]
public ProposalStatus ProposalStatus { get; set; }
[Display(Name = "İletme Şekli")]
public DeliveredBy DeliveredBy { get; set; }
[Display(Name = "Asansör Adedi")]
public int AmountOfElevators { get; set; }


public List<OfferedElevator> OfferedElevators { get; set; }
public OfferedElevator OfferedElevator { get; set; }


public int InstallationOfferId { get; set; }
[Display(Name = "Kapasite")]
public int Capacity { get; set; }
[Display(Name = "Durak")]
public int StopCount { get; set; }
[Display(Name = "Halat Adedi")]
public int MachineRopeCount { get; set; }
[Display(Name = "Askı Tipi")]
public int HangStyle { get; set; } = 1;
[Display(Name = "Tahrik Tipi")]
public DriveType DriveType { get; set; }
[Display(Name = "Ortalama Kat Yüksekliği")]
public decimal AvgFloorHeight { get; set; } = 3.00M;
[Display(Name = "Giriş Adedi")]
public int EntranceCount { get; set; } = 1;
[Display(Name = "Ekstra Kapı")]
public int AdditionalDoor { get; set; } = 1;
[Display(Name = "Ağırlık Yanda İse")]
public bool WeightInSide { get; set; }
[Display(Name = "Kapı Yüksekliği 2100 ise")]
public bool DoorHeightIs2100 { get; set; } = false;
[Display(Name = "Euro Kuru")]
public decimal CurrentEuro { get; set; }
public List<Model> Models { get; set; }
public Model Model { get; set; }
}


My View



@model Ace.ViewModels.InstallationOfferVM
@for (int i = 0; i < ViewBag.amount; i++)
{
<table class="table-sm table-striped table-dark col-md-9">
<thead>
<tr>
<th></th>
<th>Malzeme Cinsi</th>
<th>Adet</th>
<th>Liste Euro</th>
<th>Liste TL</th>
<th>İskonto</th>
<th>Toplam</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td><select asp-for="Model.Id" class="form-control" asp-
items="ViewBag.Machines"></select></td>
<td>1</td>
<td></td>
</tr>
</tbody>
</table>
</div>
<hr />
}
</form>
<div>
<a asp-action="Index">Back to List</a>
</div>









share|improve this question
























  • do not use Viewdata to pass model to view. you can pass model to view. some limiation of viewdata is stackoverflow.com/questions/15567891/….
    – Kiran Joshi
    Nov 20 '18 at 12:44












  • Could you demonstrate your View (.cshtml) file?
    – Alexander I.
    Nov 20 '18 at 12:45










  • I've noticed that I shouldn't use Viewdata to pass model to view. But I'm quite unsure how to achieve my goal so I was trying everything :)
    – Pumpkin
    Nov 20 '18 at 13:04










  • To pass the viewmodel to your view, just do return View(viewmodel);
    – ramon abacherli
    Nov 20 '18 at 13:28














0












0








0







I'm very new to programming and I got really confused how to do this..



What I'm trying to do is a table for creating an offer after picking the materials I want. Price will change while I pick different materials. At the end, I will save the offer, with total price etc.



I have a list of Product Models. And in my view, I would like to pick the product model I want in "First Column" using it's FullName and I want to populate other columns in same row with the Models' predefined details that I just picked.



I made a research how to do it. Jquery, Ajax were mentioned but I will have to add more of those dropdown lists with more Viewbags. Don't I have to write a new Ajax for each dropdown then ?



I really hope to be guided in what way I should try to do this.



Thanks in advance!



 public class Model:BaseEntity
{
public TypeOfPart TypeOfPart { get; set; }
public string BrandName { get; set; }
public string ModelName { get; set; }
public string VersionName { get; set; }
public decimal? ListPriceTL { get; set; }
public decimal? ListPriceForeign { get; set; }
public ForeignCurrency? ForeignCurrency { get; set; }
public decimal CurrentDiscount { get; set; } = 0.00M;

public int? CertificateId { get; set; }
public Certificate Certificate { get; set; }

public string FullName => $"{BrandName} {ModelName} {VersionName}";


My Controller



public IActionResult Create()
{
int amountOfElevators = Convert.ToInt32(TempData["Amount"]);
ViewBag.amount = amountOfElevators;


ViewData["Machines"] = new SelectList(_context.ModelRepo.GetAll()
.Where(x => x.TypeOfPart
==TypeOfPart.Machine),"Id","FullName");



ViewData["ConstructionCompanyId"] = new
SelectList(_context.ConstructionCompanyRepo.GetAll(), "Id", "Name","Id");
ViewData["EmployeeId"] = new
SelectList(_context.EmployeeRepo.GetAll(), "Id", "FullName");
return View();
}


Here's the image for a little more description of what I need



EDIT:
My View Model



public class InstallationOfferVM
{
public InstallationOfferVM()
{
OfferedElevators = new List<OfferedElevator>();
Models = new List<Model>();
}
public int Id { get; set; }
[Display(Name = "Toplam ₺")]
public decimal TotalPriceTL { get; set; }
[Display(Name = "Toplam €")]
public decimal TotalPriceEuro { get; set; }
[Display(Name = "Açıklama")]
public string Description { get; set; }
[Display(Name = "Müşteri Firma")]
public int ConstructionCompanyId { get; set; }
[Display(Name = "Müşteri Firma")]
public string CompanyName { get; set; }
public ConstructionCompany ConstructionCompany { get; set; }
[Display(Name = "Teklif Tarihi")]
[DataType(DataType.Date)]
public DateTime DateOfProposal { get; set; }
[Display(Name = "Teklifi Veren")]
public int EmployeeId { get; set; }
[Display(Name = "Teklifi Veren")]
public string EmployeeFullName { get; set; }
public Employee Employee { get; set; }
[Display(Name = "Teklif Durumu")]
public ProposalStatus ProposalStatus { get; set; }
[Display(Name = "İletme Şekli")]
public DeliveredBy DeliveredBy { get; set; }
[Display(Name = "Asansör Adedi")]
public int AmountOfElevators { get; set; }


public List<OfferedElevator> OfferedElevators { get; set; }
public OfferedElevator OfferedElevator { get; set; }


public int InstallationOfferId { get; set; }
[Display(Name = "Kapasite")]
public int Capacity { get; set; }
[Display(Name = "Durak")]
public int StopCount { get; set; }
[Display(Name = "Halat Adedi")]
public int MachineRopeCount { get; set; }
[Display(Name = "Askı Tipi")]
public int HangStyle { get; set; } = 1;
[Display(Name = "Tahrik Tipi")]
public DriveType DriveType { get; set; }
[Display(Name = "Ortalama Kat Yüksekliği")]
public decimal AvgFloorHeight { get; set; } = 3.00M;
[Display(Name = "Giriş Adedi")]
public int EntranceCount { get; set; } = 1;
[Display(Name = "Ekstra Kapı")]
public int AdditionalDoor { get; set; } = 1;
[Display(Name = "Ağırlık Yanda İse")]
public bool WeightInSide { get; set; }
[Display(Name = "Kapı Yüksekliği 2100 ise")]
public bool DoorHeightIs2100 { get; set; } = false;
[Display(Name = "Euro Kuru")]
public decimal CurrentEuro { get; set; }
public List<Model> Models { get; set; }
public Model Model { get; set; }
}


My View



@model Ace.ViewModels.InstallationOfferVM
@for (int i = 0; i < ViewBag.amount; i++)
{
<table class="table-sm table-striped table-dark col-md-9">
<thead>
<tr>
<th></th>
<th>Malzeme Cinsi</th>
<th>Adet</th>
<th>Liste Euro</th>
<th>Liste TL</th>
<th>İskonto</th>
<th>Toplam</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td><select asp-for="Model.Id" class="form-control" asp-
items="ViewBag.Machines"></select></td>
<td>1</td>
<td></td>
</tr>
</tbody>
</table>
</div>
<hr />
}
</form>
<div>
<a asp-action="Index">Back to List</a>
</div>









share|improve this question















I'm very new to programming and I got really confused how to do this..



What I'm trying to do is a table for creating an offer after picking the materials I want. Price will change while I pick different materials. At the end, I will save the offer, with total price etc.



I have a list of Product Models. And in my view, I would like to pick the product model I want in "First Column" using it's FullName and I want to populate other columns in same row with the Models' predefined details that I just picked.



I made a research how to do it. Jquery, Ajax were mentioned but I will have to add more of those dropdown lists with more Viewbags. Don't I have to write a new Ajax for each dropdown then ?



I really hope to be guided in what way I should try to do this.



Thanks in advance!



 public class Model:BaseEntity
{
public TypeOfPart TypeOfPart { get; set; }
public string BrandName { get; set; }
public string ModelName { get; set; }
public string VersionName { get; set; }
public decimal? ListPriceTL { get; set; }
public decimal? ListPriceForeign { get; set; }
public ForeignCurrency? ForeignCurrency { get; set; }
public decimal CurrentDiscount { get; set; } = 0.00M;

public int? CertificateId { get; set; }
public Certificate Certificate { get; set; }

public string FullName => $"{BrandName} {ModelName} {VersionName}";


My Controller



public IActionResult Create()
{
int amountOfElevators = Convert.ToInt32(TempData["Amount"]);
ViewBag.amount = amountOfElevators;


ViewData["Machines"] = new SelectList(_context.ModelRepo.GetAll()
.Where(x => x.TypeOfPart
==TypeOfPart.Machine),"Id","FullName");



ViewData["ConstructionCompanyId"] = new
SelectList(_context.ConstructionCompanyRepo.GetAll(), "Id", "Name","Id");
ViewData["EmployeeId"] = new
SelectList(_context.EmployeeRepo.GetAll(), "Id", "FullName");
return View();
}


Here's the image for a little more description of what I need



EDIT:
My View Model



public class InstallationOfferVM
{
public InstallationOfferVM()
{
OfferedElevators = new List<OfferedElevator>();
Models = new List<Model>();
}
public int Id { get; set; }
[Display(Name = "Toplam ₺")]
public decimal TotalPriceTL { get; set; }
[Display(Name = "Toplam €")]
public decimal TotalPriceEuro { get; set; }
[Display(Name = "Açıklama")]
public string Description { get; set; }
[Display(Name = "Müşteri Firma")]
public int ConstructionCompanyId { get; set; }
[Display(Name = "Müşteri Firma")]
public string CompanyName { get; set; }
public ConstructionCompany ConstructionCompany { get; set; }
[Display(Name = "Teklif Tarihi")]
[DataType(DataType.Date)]
public DateTime DateOfProposal { get; set; }
[Display(Name = "Teklifi Veren")]
public int EmployeeId { get; set; }
[Display(Name = "Teklifi Veren")]
public string EmployeeFullName { get; set; }
public Employee Employee { get; set; }
[Display(Name = "Teklif Durumu")]
public ProposalStatus ProposalStatus { get; set; }
[Display(Name = "İletme Şekli")]
public DeliveredBy DeliveredBy { get; set; }
[Display(Name = "Asansör Adedi")]
public int AmountOfElevators { get; set; }


public List<OfferedElevator> OfferedElevators { get; set; }
public OfferedElevator OfferedElevator { get; set; }


public int InstallationOfferId { get; set; }
[Display(Name = "Kapasite")]
public int Capacity { get; set; }
[Display(Name = "Durak")]
public int StopCount { get; set; }
[Display(Name = "Halat Adedi")]
public int MachineRopeCount { get; set; }
[Display(Name = "Askı Tipi")]
public int HangStyle { get; set; } = 1;
[Display(Name = "Tahrik Tipi")]
public DriveType DriveType { get; set; }
[Display(Name = "Ortalama Kat Yüksekliği")]
public decimal AvgFloorHeight { get; set; } = 3.00M;
[Display(Name = "Giriş Adedi")]
public int EntranceCount { get; set; } = 1;
[Display(Name = "Ekstra Kapı")]
public int AdditionalDoor { get; set; } = 1;
[Display(Name = "Ağırlık Yanda İse")]
public bool WeightInSide { get; set; }
[Display(Name = "Kapı Yüksekliği 2100 ise")]
public bool DoorHeightIs2100 { get; set; } = false;
[Display(Name = "Euro Kuru")]
public decimal CurrentEuro { get; set; }
public List<Model> Models { get; set; }
public Model Model { get; set; }
}


My View



@model Ace.ViewModels.InstallationOfferVM
@for (int i = 0; i < ViewBag.amount; i++)
{
<table class="table-sm table-striped table-dark col-md-9">
<thead>
<tr>
<th></th>
<th>Malzeme Cinsi</th>
<th>Adet</th>
<th>Liste Euro</th>
<th>Liste TL</th>
<th>İskonto</th>
<th>Toplam</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td><select asp-for="Model.Id" class="form-control" asp-
items="ViewBag.Machines"></select></td>
<td>1</td>
<td></td>
</tr>
</tbody>
</table>
</div>
<hr />
}
</form>
<div>
<a asp-action="Index">Back to List</a>
</div>






c# model-view-controller core






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 13:58







Pumpkin

















asked Nov 20 '18 at 12:39









PumpkinPumpkin

12




12












  • do not use Viewdata to pass model to view. you can pass model to view. some limiation of viewdata is stackoverflow.com/questions/15567891/….
    – Kiran Joshi
    Nov 20 '18 at 12:44












  • Could you demonstrate your View (.cshtml) file?
    – Alexander I.
    Nov 20 '18 at 12:45










  • I've noticed that I shouldn't use Viewdata to pass model to view. But I'm quite unsure how to achieve my goal so I was trying everything :)
    – Pumpkin
    Nov 20 '18 at 13:04










  • To pass the viewmodel to your view, just do return View(viewmodel);
    – ramon abacherli
    Nov 20 '18 at 13:28


















  • do not use Viewdata to pass model to view. you can pass model to view. some limiation of viewdata is stackoverflow.com/questions/15567891/….
    – Kiran Joshi
    Nov 20 '18 at 12:44












  • Could you demonstrate your View (.cshtml) file?
    – Alexander I.
    Nov 20 '18 at 12:45










  • I've noticed that I shouldn't use Viewdata to pass model to view. But I'm quite unsure how to achieve my goal so I was trying everything :)
    – Pumpkin
    Nov 20 '18 at 13:04










  • To pass the viewmodel to your view, just do return View(viewmodel);
    – ramon abacherli
    Nov 20 '18 at 13:28
















do not use Viewdata to pass model to view. you can pass model to view. some limiation of viewdata is stackoverflow.com/questions/15567891/….
– Kiran Joshi
Nov 20 '18 at 12:44






do not use Viewdata to pass model to view. you can pass model to view. some limiation of viewdata is stackoverflow.com/questions/15567891/….
– Kiran Joshi
Nov 20 '18 at 12:44














Could you demonstrate your View (.cshtml) file?
– Alexander I.
Nov 20 '18 at 12:45




Could you demonstrate your View (.cshtml) file?
– Alexander I.
Nov 20 '18 at 12:45












I've noticed that I shouldn't use Viewdata to pass model to view. But I'm quite unsure how to achieve my goal so I was trying everything :)
– Pumpkin
Nov 20 '18 at 13:04




I've noticed that I shouldn't use Viewdata to pass model to view. But I'm quite unsure how to achieve my goal so I was trying everything :)
– Pumpkin
Nov 20 '18 at 13:04












To pass the viewmodel to your view, just do return View(viewmodel);
– ramon abacherli
Nov 20 '18 at 13:28




To pass the viewmodel to your view, just do return View(viewmodel);
– ramon abacherli
Nov 20 '18 at 13:28












1 Answer
1






active

oldest

votes


















0














I would suggest to change your controller method this way:



public IActionResult Create()
{
var offeredElevators = //query here to get the offeredElevators
var viewmodel = new InstallationOfferVM
{
OfferedElevators = offeredElevators,
Models = new List<Model>()
};

return View(viewmodel);
}


this way you can at least get your data to the view, how it is supposed to be done. I am not sure if i agree with your model/viewmodel though..



hope this helps a little at least






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393195%2fmvc-core-trying-to-fill-a-table-row-by-selecting-first-column%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I would suggest to change your controller method this way:



    public IActionResult Create()
    {
    var offeredElevators = //query here to get the offeredElevators
    var viewmodel = new InstallationOfferVM
    {
    OfferedElevators = offeredElevators,
    Models = new List<Model>()
    };

    return View(viewmodel);
    }


    this way you can at least get your data to the view, how it is supposed to be done. I am not sure if i agree with your model/viewmodel though..



    hope this helps a little at least






    share|improve this answer


























      0














      I would suggest to change your controller method this way:



      public IActionResult Create()
      {
      var offeredElevators = //query here to get the offeredElevators
      var viewmodel = new InstallationOfferVM
      {
      OfferedElevators = offeredElevators,
      Models = new List<Model>()
      };

      return View(viewmodel);
      }


      this way you can at least get your data to the view, how it is supposed to be done. I am not sure if i agree with your model/viewmodel though..



      hope this helps a little at least






      share|improve this answer
























        0












        0








        0






        I would suggest to change your controller method this way:



        public IActionResult Create()
        {
        var offeredElevators = //query here to get the offeredElevators
        var viewmodel = new InstallationOfferVM
        {
        OfferedElevators = offeredElevators,
        Models = new List<Model>()
        };

        return View(viewmodel);
        }


        this way you can at least get your data to the view, how it is supposed to be done. I am not sure if i agree with your model/viewmodel though..



        hope this helps a little at least






        share|improve this answer












        I would suggest to change your controller method this way:



        public IActionResult Create()
        {
        var offeredElevators = //query here to get the offeredElevators
        var viewmodel = new InstallationOfferVM
        {
        OfferedElevators = offeredElevators,
        Models = new List<Model>()
        };

        return View(viewmodel);
        }


        this way you can at least get your data to the view, how it is supposed to be done. I am not sure if i agree with your model/viewmodel though..



        hope this helps a little at least







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 '18 at 13:34









        ramon abacherliramon abacherli

        859




        859






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393195%2fmvc-core-trying-to-fill-a-table-row-by-selecting-first-column%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Paul Cézanne

            UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

            Angular material date-picker (MatDatepicker) auto completes the date on focus out