c# - Posting Razor textarea back to controller -


i have viewmodel wraps 2 lists of different objects: list<review> reviews , daycommentary daycommentary reviewviewmodel. in view, group reviews review.country:

var groupedreviews = model.reviews.groupby(item => item.country) 

in view, loop through groupedreviews , build html table each group. goal output each review in group while still binding model posting controller. important because in view have textarea field needs pass entered text controller during post actions. understand requires for-loop rather foreach maintain binding.

i've tried following, displays correctly in view not bind model during formmethod.post, example during add/edit/delete controller action:

@using (html.beginform("save", "review", formmethod.post)) {     foreach (var group in groupedreviews)     {         <h6>@html.raw(group.key)</h6>         <table>             <tr>                 <th style="text-align: center">                     @html.displaynamefor(model => model.reviews[0].ticker)                 </th>             </tr>             @for (var = 0; < group.count(); i++)             {                 <tr>                     <td style="text-align: center">                         @html.textareafor(model => group.elementat(i).commentary)                         @html.hiddenfor(model => group.elementat(i).commentary)                     </td>                 </tr>             }         </table>     } } 

i'm pretty sure problem here elementat(i), can use instead when iterating through type of grouped collection?

i've tried assigning name , id attributes textarea field suggested in answers similar questions no avail.

i've been going in circles trying use different types of loops , iterating on different collections nothing achieves desired goal.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -