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

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -