-1

Hi Guys.My problem is that i won't be able to display data that is coming from my controller to my view. i got this error.Someone can help me please !

    @model GRHModel.ListeDemandeConger
   @{
   ViewBag.Title = "AfficherMesDemandes";
   Layout = "~/Views/Home/Common.cshtml";
   }

   <table class="table table-responsive" style="width:400px">
   @foreach (var dc in  Model.ldc)
   {

    <tr>
        <td>
            @Html.DisplayFor(i =>dc.DateDebut)
        </td>
    </tr>

   }

   </table>
user9405863
  • 1,476
  • 1
  • 9
  • 16
  • 2
    Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Igor Mar 28 '18 at 16:43
  • where you are getting error? – user9405863 Mar 29 '18 at 03:51

1 Answers1

0

You model is null. Surround your foreach with an IF checking if the model != null.

@if (Model != null)
{
   your foreach
}
Rodrigo Werlang
  • 1,909
  • 1
  • 15
  • 27