0
I have a problem when creating a table with dynamic columns. I add the columns in a loop this way:
for (int i = 0; i < attrIds.Count; i++)
{
resource_attr attr = resourceAttrRepository.Find(attrIds[i]);
int local = i;
columns.Add(new WebGridColumn()
{
ColumnName = attr.code,
Header = attr.resource_attr_name,
Style = "column-attr",
CanSort = true,
Format = (item) => (((List<string>)item.attrValues).Count < local) ? @item.attrValues[local] : "out"
});
}
The header column is correct, but the value is always appearing "out".
I am using ASP.Net MVC 4 and the Webgrid component.
yes, but because it always falls on Else? debugging I see that the local variable is always greater than the amount of objects within the item list.attrValues
– AndrehOdon