New MVC field not displaying

I'm trying to add another column to a table on an existing MVC site by adding the following lines:

Snippet of Model:

public partial class viewUserRecord
{
    [Display(Name = "Agent ID")]
    public Nullable<int> agentId { get; set; }

    ...
    ....

    // New code:
    [Display(Name = "Mailing Zip")]
    public string mailingZip { get; set; }
}

View:

<tr role="row">
     <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Rendering engine: activate to sort column ascending">
             @Html.DisplayNameFor(model => model.agentId)
     </th>

     ...
     ....


     <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Rendering engine: activate to sort column ascending">
             @Html.DisplayNameFor(model => model.mailingZip)
     </th>
</tr>

<tbody>
    @foreach (var item in Model)
    {
        <tr>
           <td>
              @Html.DisplayFor(modelItem => item.agentId) // debugger shows correct value here
          </td>

          ...
          ....

          <td>
              @Html.DisplayFor(modelItem => item.mailingZip)  // debugger shows NULL here
          </td>
        </tr>
     }
</tbody>

This adds the new column to the table but does not retrieve the relevant data.

The model references a database view viewUserDetails which contains the correct data for the new field, mailingZip, but debugging through the view shows the contents as NULL.

The Agent ID field displays fine.

I realise I've missed something but have become stumped.

Answers


have you tried

[Display(Name = "Agent ID")]
public int id { get; set; }

instead of

public int id { get; set; }
[Display(Name = "Agent ID")]

?


Need Your Help

Contact Form with PHPMailer

php forms phpmailer

I have a very simple form consisting of:

Active Record Validations, presence of not working

ruby-on-rails ruby forms validation

I'm working on a form to create new users for a Ruby on Rails project. I'd like to start by mentioning that the form itself works just fine when filled out correctly and creates users exactly the r...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.