mercredi 22 juillet 2015

Templates can be used only with field access, on razor view

I am trying to bind a KeyValuePair VALUE in a asp.net mvc view, however I get this error above.

How can I fix this?

@using Microsoft.Azure.ActiveDirectory.GraphClient
@using xx.Utils
@model IEnumerable<User>


@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/GlobalAdmin/Views/Shared/_LayoutGlobalAdmin.cshtml";
}
<h2>Usuarios</h2>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>Lista de Usuarios</h5>
                    <div class="ibox-tools">
                        @Html.ActionLink("Create New", "Create", null, new { @class = "btn btn-primary btn-xs" })
                    </div>
                </div>
                <div class="ibox-content">

                    <table id="directoryObjects" class="table table-bordered table-striped">
                        <tr>
                            <th>
                                UserPrincipalName
                            </th>
                            <th>
                                DisplayName
                            </th>
                            <th>
                                JobTitle
                            </th>
                            <th>
                                ObjectId
                            </th>
                            <th />
                        </tr>
                        @foreach (var item in Model)
                        {
                            var user = item as User;
                        <tr>
                            <td>
                                @Html.DisplayFor(modelItem => user.UserPrincipalName)
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => user.DisplayName)
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => user.JobTitle)
                            </td>
                            <td>
                                @{ 
                                    string extPropLookupName = string.Format("extension_{0}_{1}", SettingsHelper.ClientId.Replace("-", ""), "Compania");
                                }
                                @Html.DisplayFor(modelItem => user.GetExtendedProperties().Where(prop => prop.Key == extPropLookupName).FirstOrDefault());
                            </td>
                            <td>
                                @Html.ActionLink("Edit", "Edit", new { objectId = item.ObjectId }) <br />
                                @Html.ActionLink("Details", "Details", new { objectId = item.ObjectId }) <br />
                                @Html.ActionLink("Delete", "Delete", new { objectId = item.ObjectId })  <br />
                                @Html.ActionLink("GroupMembership", "GetGroups", new { objectId = item.ObjectId }) <br />
                                @Html.ActionLink("DirectReports", "GetDirectReports", new { objectId = item.ObjectId }) <br />
                            </td>
                        </tr>
    }
                    </table>

                </div>
            </div>
        </div>
    </div>
</div>

Aucun commentaire:

Enregistrer un commentaire