I have a textarea that represents a description field. The descriptions have commas so when trying to split the field's descriptions the data is not parsed correctly. How can I get each row's description correctly.
var DescList = FormValues["Item.Description"].Split(',').Select(item => item).ToList<string>();
//will not work for obvious reasons. Comma delimited FormCollection has commas to identify separate row data.
It seems like Microsoft designed the FormsCollection without the textarea control in mind. A text area with commas will not work when trying to access each value. What is interesting is that the _entriestables property has it in the perfect format but they chose to make it a private property. Very frustrating.
`
Here is the important part of my viewmodel.
public class TenantViewModel
{
public Tenant Tenant { get; set; }
public Site Site { get; set; }
}
My view is populated like this:
if (Model != null && Model.Tenant != null && Model.Tenant.Site != null && Model.Tenant.Site.Count() > 0)
{<div class="detailsbox_view">
<table id="tblTenantSites">
<tr>
<th>@Html.LabelFor(item => item.Site.Title)</th>
<th>@Html.LabelFor(item => item.Site.Description)</th>
</tr>
@foreach (var Item in Model.Tenant.Sites)
{
<tr>
@Html.HiddenFor(modelItem => Item.SiteId)
<td>
@Html.EditorFor(modelItem => Item.Title)
</td>
<td>
@Html.TextAreaFor(modelItem => Item.Description, new {@width="400" })
</td>
</tr> }
</table>
As you see this site table is a child of Tenant object. This child record does not get automatically updated using this method but the Tenant data does automatically get updated. This is the reason I tried the FormColelction instead. Is there something I am missing to make this work?
FormValues['whatever']. You should be submitting the model back to the Controller