Is there a way to use a condition in the ASP MVC3 @Html.DisplayFor() control? Below is the syntax I attempted. While it seems the partner.TradingPartners is able to use .Where<>, according to Visual Studio I am doing it wrong!
Here is the syntax I use
@foreach (var item in Model.Agent.SymNumberToAgentId)
{
var gogo = ViewBag.Periscope + item.AgentId.Trim();
<tr>
<td>
@Html.DisplayFor(modelItem => item.DisplayAgentId)
</td>
<td>
@Html.DisplayFor(modelItem => item.CompanyCode)
</td>
<td>
@foreach (var partner in Model.AgentIdDetails)
{
@Html.DisplayFor(modelItem => partner.TradingPartners.Where(item => item.AgentId == partner.AgentId))
}
</td>
<td>
@Html.ActionLink("Remove", "Delete", "SymetraNumberToAgentId", new { id = item.SymetraNumber, aid=item.AgentId}, null)
</td>
<td>
<a href=@gogo target="_blank">View in Periscope</a>
</td>
</tr>
}
and here is the error message
CS1928: 'System.Collections.Generic.IList<string>' does not contain a definition for 'Where' and the best extension method overload 'System.Linq.Enumerable.Where<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,bool>)' has some invalid arguments