asp.net mvc - Trying to display a variable in a for loop inside of razor with C#/Linq -


i trying loop through set of numbers , display them on scorecard. if step through code, variable returns correct values, can't them display.

    @foreach (var g in model)     {         @html.raw(string.format("<tr>"))             int grossscore = 0;              @html.raw(string.format("<td>{0}</td>", g.playername))         (int s = 0; s < 18; s++)         {             @html.raw(string.format("<td>"));              int holescore = 0;             var bretak = @g.scores.take(1).skip(s).firstordefault();             var werwee = @g.scores.where(b => b.hole == s + 1).select(i => i.score).firstordefault();             //if (bretak.score > 0)             //{             //    holescore = bretak.score;             //}              holescore = werwee;              html.raw(string.format("{0}", holescore));             //@html.tostring(holescore);             //html.raw(holescore);             @html.raw(string.format("<td>" + @holescore + "</td>"));             grossscore = grossscore + holescore;              @html.raw(string.format("</td>"));         }             @html.raw(string.format("<td>{0}</td>", grossscore))              @html.raw(string.format("<td align=\"center\"> <button type=\"button\" class=\"btn btn-default btn-xs editbtn\" data-player-id=\"'{0}'\">edit </button></td>", g.gameid))             @html.raw(string.format("<td> <button type=\"button\" class=\"btn btn-default btn-xs deletebtn\" data-player-id=\"'{0}'\">delete </button></td>", g.gameid))          @html.raw("</tr>")      } 

player name displays correctly , grossscore variable calculates , displays correctly. correct number of boxes inside loop holescore won't display. sorry may little messy left of code in show of things have tried.

i think misunderstood html.raw, used decode string html string, not outputting , output type instead of

@html.raw(string.format("<td>" + @holescore + "</td>")); 

just use

<td> @holescore</td> 

i suggest going through this clearer picture assume didn't based on code above.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -