Reputation: 73
Here I am trying to display variable y
value in td
in view(i.e .cshtml).
But have no idea how to do that.
Below is my view:
<td>
@Html.DisplayFor(modelItem => item.District)
</td>
<td>
@{
var y = v.GetContestantAverageRatingByContestantId(item.ContestantId);
}
</td>
Upvotes: 4
Views: 22837
Reputation: 61
Did you try this?
<td>
@Html.DisplayFor(modelItem => item.District)
</td>
<td>
@Html.Raw(v.GetContestantAverageRatingByContestantId(item.ContestantId))
</td>
Upvotes: 0
Reputation: 1635
Using Razor’s @
. Try this code:
@{
var y = v.GetContestantAverageRatingByContestantId(item.ContestantId);
}
<td>
@Html.DisplayFor(modelItem => item.District)
</td>
<td>
@y
</td>
Upvotes: 0
Reputation: 39946
There are several ways. For example simply using @
like this:
<td>
@y
</td>
Or by using a <span>
tag like this:
<span>Your Text @(y) ...</span>
Or using Html.Label
helper:
@Html.Label("lblName", y)
Upvotes: 8