asp.net - Display list of values in MVC Detail View -
I am new to web app, mvc, and linkto sql. I am using a Nviddinner tutorial as a guide using an MVC The web app is created. Now I am adding many relationships to him and just moving in the walls at every step Edit and I have a multilevel list in Create View. I want to list the selected values for the extension and list views.
I have 3 tables: company, subcontract, and a link table company.ToSatabacktract I have a code that is found in the company of the companies I have selected from the Associate Tablet, which used somewhere else in my code goes. I do not know how to display it
Should I write another function to get company name from company table? Do I pass a list of names of subcontract delivious views and then loop anyway through them?
Along with viewing the sub-contract index, question. The index view table is in the form, I have to make a "company" column, which has a comma-separated list of companies for each subcontract line.
[Authorized] Public Transaction Details (String ID) {Sub-Property Sub-Property = Sub-contractor Repository. Gates Bactroit (ID); IEnumerable & LT; Guid & gt; Cmpx = subcontractRepository.GetSubcontractCompanies (subcontract. subcontract_id); See Return (subcontract == blank) ("Notepad"); Else {See Return ("Details", sub-contract); }} [Authorized] Public Performance Index () {var sub-contracts = sub-contractor repository.FindlesBanktracts (). ToList (); See refund ("index", sub contract); } You have several options: 1) You can create a new square sub-section. Contract & amp; Pass an object of new class for IEnumerable and visualization. This is common in ASP.NET MVC. Public class MyCustomModelView {public IEnumerable & lt; Guid & gt; Company {Received; Set; } Public Sub-Property Subdivision [Received; Set; }}
and in the controller:
Return view ("Details", new MyCustomModelView () {company = CPP, subcontract = subcontract });
And this new type should be the type of your view.
Enter the code here
2) Also you can add IEnumerable to ViewData collection like this:
< Code> ViewData ["Company"] = cmp_;
and then access it with the indexer to see it
& lt;% foreach (iNewMarble & gt; Guid & gt (ViewData) ["Company"];)) {% & gt; ... display name ... & lt;%}% & gt;
I will re-enter the FIR individually because you do not need to insert it and this is cleaner