websss
asked on
Foreach viewbag object - filter by ID ?
I have the following html code
This works well with 1 enterprise
But when I add 2 enterprises to the results, it list like this
Ent1
- site1
- site2
- site3
Ent2
- site1
- site2
- site3
instead of
Ent1
- site2
- site3
Ent2
- site1
How do adjust the code so it only shows the correct data
Inside SITE there is a EnterpriseId
i.e. s.EnterpriseId
So I would need a where clause or something similar in razor?
@foreach (var e in ViewBag.Enterprise)
{
<li class="configurator-enterprise-li" id="@e.Id">
<span>@e.Name</span>
<ul id="site-ul">
@foreach (var s in ViewBag.Sites)
{
<li class="site-li" id="@s.SiteId">@s.SiteName</li>
}
...
This works well with 1 enterprise
But when I add 2 enterprises to the results, it list like this
Ent1
- site1
- site2
- site3
Ent2
- site1
- site2
- site3
instead of
Ent1
- site2
- site3
Ent2
- site1
How do adjust the code so it only shows the correct data
Inside SITE there is a EnterpriseId
i.e. s.EnterpriseId
So I would need a where clause or something similar in razor?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.