説明フィールドを表すテキストエリアがあります。説明にはカンマが含まれているため、フィールドの説明を分割しようとすると、データが正しく解析されません。各行の説明を正しく取得するにはどうすればよいですか。
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.
Microsoft は、テキストエリア コントロールを考慮せずに FormsCollection を設計したようです。各値にアクセスしようとすると、コンマを含むテキスト領域は機能しません。興味深いのは、_entriestables プロパティが完全な形式でそれを持っていることですが、彼らはそれをプライベート プロパティにすることを選択しました。とてもイライラします。
`
Here is the important part of my viewmodel.
public class TenantViewModel
{
public Tenant Tenant { get; set; }
public Site Site { get; set; }
}
私のビューは次のように取り込まれます:
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>
ご覧のとおり、このサイト テーブルは Tenant オブジェクトの子です。この子レコードはこのメソッドを使用して自動的に更新されませんが、テナント データは自動的に更新されます。これが、代わりに FormColelction を試した理由です。この作業を行うために欠けているものはありますか?