0

I have one view with the following info

  1. Company Info
  2. List of Company Address
  3. List of Company User

For Company Info, I design with @Html.TextBoxFor(model => model.SingleClient.CompanyNameEN) and other info are the same

For List of Company Address, I use

@foreach (ClientAddress u in Model.List_ClientAddress)
{
    <td>@Html.EditorFor(model => u.Director)</td>
}

For List of Company User, I use the same as Company Address.

My question is I have no idea how to send back all value ( Update Company info, Company Address List, Company User Info to Controller.

Noted:

I use @using(Html.BeginForm("UpdatePost", "Company", FormMethod.Post)) ... button submit inside

In Controller Index Controller

viewCollection collection = new viewCollection();
collection.SingleClient = gen.list_of_client().ToList().Where(x => x.ClientCode == client).FirstOrDefault();
 collection.List_CompanyAddress = gen.List_of_CompanyAddress().Where(x => x.ClientCode == client).ToList(); 
collection.List_ClientUser = gen.List_of_ClientUser().Where(x => x.ClientCode == client).ToList();
return View(collection);

Update Controller

collection.SingleClient.CompanyNameEN; //Return Null
collection.SingleClient.CompanyNameKH // Return NUll
List<ClientAddress> cadd = collection.List_ClientAddress;(Return Null)
List<ClientSharedHolder> csh = collection.List_ClientShared; (Return Null)

So Please help to advice me how to solve this problem? as I have no idea about this.

  • 3
    Suggest you start by reading [this answer](http://stackoverflow.com/questions/30094047/html-table-to-ado-net-datatable/30094943#30094943) to understand how to generate form controls for a collection –  May 01 '18 at 10:56
  • I agree with @StephenMuecke but can you also decompose your views instead of clogging them? – Jack M May 01 '18 at 10:59

0 Answers0