I have a view in which I receive a list of properties via reflection. These can be single items as well as collections. I wish to print them (the single value or a joined string).
How can I convert a collection to a joined string? I tried (among other things) the following, but this does not work:
@foreach (var cell in Model.GetData().ToList())
{
<td>
@{ var value = cell.GetValue(row, null);}
@(cell.IsCollection() ?
String.Join(", ", (value as IEnumerable<object>).Select(o => o.ToString()).Select(o => o.ToString())) : value)
</td>
}
Does anyone know how I can do this correctly?
Aucun commentaire:
Enregistrer un commentaire