c# - razor html output result -
i trying output results in @helpers code , code looks this
@helpers listfiles(string id, string cnumber,){ foreach(loopitem in getloop("items")){ if(i.getvalue("userid") == id){ <li>@i.getvalue("name")</li> }else{ if(i.getvalue("userid") != id){ <li>@i.getvalue("name")</li> } } } }
as result li elements want if statement true should wrap li elements in ul element , else statement should wrap li in new ul element. please
one possible way using 2 foreach
, 1 each user id group :
@helpers listfiles(string id, string cnumber,){ <ul> foreach(loopitem in getloop("items").where(o => o.getvalue("userid") == id)){ <li>@i.getvalue("name")</li> } </ul> <ul> foreach(loopitem in getloop("items").where(o => o.getvalue("userid") != id)){ <li>@i.getvalue("name")</li> } </ul> }
Comments
Post a Comment