Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Display Variable Value In View?

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>
like image 643
CarrotCrop Avatar asked Oct 18 '25 23:10

CarrotCrop


1 Answers

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)
like image 84
Salah Akbari Avatar answered Oct 20 '25 12:10

Salah Akbari



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!