0

I have this view :

    @model IEnumerable<sn.Models.Order>



 <h2>

    **Name of Recipients**

 </h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
           Last Name
        </th>
        <th>
            Mark
        </th>
        <th>
           Quiz Number
        </th>
        <th>
          Pass
        </th>
        <th>
           Paid
        </th>
        <th>
           Mark Date
        </th>
     </tr>

@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Customer.LastName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Mark)
        </td>
        <td>
                @Html.DisplayFor(modelItem => item.QuizNo)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Pass)
            </td>
             <td>
                @Html.DisplayFor(modelItem => item.Paid)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.MarkDate)
            </td>
          </tr>
    }

</table>

below is an image showing my view: View

I want to display the LastName in place of Name of Recipients . The item LastName does not change for a particular customer. This view is showing the details of that user and this is part of the code I used to get the results in my controller:

var certificateDetails = db.orders.Where(p => p.ID == id);
return View( certificateDetails.ToPagedList(pageNumber, pageSize));

1 Answer 1

3
<h2>
    @(Model.Any() ? Model.First().Customer.LastName : "")
</h2>
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the response. I am getting this error after executing the code changes you gave me: CS0119: 'System.Linq.ParallelEnumerable.First<TSource>(System.Linq.ParallelQuery<TSource>, System.Func<TSource,bool>)' is a 'method', which is not valid in the given context its highlight the changes in question.
I have forgotten the parentheses behind First. I have edited my answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.