I’m trying to pull from a List collection of comments in the View using Razor and Microsoft’s HTML helper for TextArea (@Html.TextAreaFor). I can easily populate single comments, but how do I add the ENTIRE list collection of comments to the textarea? Here’s an example of what I use to display single comments:
@Html.TextAreaFor(x => x.AuditDoc.PrivateComment, 0, 0, false)
That’s all well and good, but how do I append a second, third, and fourth comment to that SAME textarea? Is there a way to bind an entire list collection to that html.textarea helper? Preferably, I’d like to do this in Razor using html helpers. If that’s not possible, I’d appreciate any advice about how to do it with Jquery. NOTE: The comments don’t have to be bound to the model. So I’d be fine just using @Html.TextArea instead of @Html.TextAreaFor. The array of comments is strictly for display. So there’s no complications of multi-select etc.
Well you could do the concatenation in the controller and pass it to the view read to be set into the text area:
Controller Logic:
Then in the View I did this:
Obviously my code will return them all pretty ugly, but you could do: