I'm looping through a multiple textbox datatype with leblender and as soon as I try to group the items it returns "System.Linq.Lookup2+Grouping[System.Int32,System.String]" instead of the value. Any ideas?
Works:
var istArray = editor.GetValue<Newtonsoft.Json.Linq.JArray>("list");
var istArrayStrings = istArray.Select(x => (string)x["value"]);
@foreach(var item in listArrayStrings) {
<li>@item</li>
}
but this just returns the string above instead of the value:
@foreach(var item in listArrayStrings.InGroupsOf(2)) {
In your example, @item is an IEnumerable which is why you see the result you do. You need to do something more with the collection in order to render it's contents. Perhaps something along the following lines:
var listArrayStrings = new[] { "StringOne", "StringTwo", "StringThree", "StringFour" };
foreach (var item in listArrayStrings.InGroupsOf(2))
{
@string.Join(", ", item)
}
Which should produce results similar to this I think:
Gruoped items returns System.Linq.Lookup`2+Grouping[System.Int32,System.String]
Hi,
I'm looping through a multiple textbox datatype with leblender and as soon as I try to group the items it returns
"System.Linq.Lookup2+Grouping[System.Int32,System.String]"
instead of the value. Any ideas?Works:
Thanks!
Amir
In your example,
@item
is anIEnumerable
which is why you see the result you do. You need to do something more with the collection in order to render it's contents. Perhaps something along the following lines:Which should produce results similar to this I think:
Hope that helps!
Sorry for the late reply. That did the trick, thanks Simon!
is working on a reply...