0

I'm a beginner in ASP.NET MVC and i began a small project. I created CRUD methods in my controller and it works. I just have a problem with a method i created to see the details of a form (my project is to create forms with a backoffice). I'll show you the code:

The controller:

public ActionResult Detail(Guid id)
    {
        Form formDetail = null;

        using (var ctx = new FormsContext())
        {
            formDetail = ctx.Forms.Find(id);
        }

        return View(formDetail);
    }

The model:

public class Form
{
    public Guid FormId { get; set; }
    public string Titre { get; set; }
    public string Description { get; set; }
    public string DateCloture { get; set; }
    public List<string> ListeQuestions { get; set; }
}

And the view:

@model ProjetESGIForm.Models.Form

@{
    ViewBag.Title = "Detail";
}

<h2>Detail</h2>

<table>
    <tr>
        <td>
            @Html.LabelFor(m => m.Titre)
        </td>
        <td>
            @Html.LabelFor(m => m.Description)
        </td>
        <td>
            @Html.LabelFor(m => m.DateCloture)
        </td>
    </tr>
</table>

When I debug the project all the views work except the detail one ... I have the titre description and datecloture but no datas ...

If you have any idea, you're welcome !

Thanks.

1 Answer 1

1

Change View to :

<table>
<tr>
    <td>
        @Html.LabelFor(m => m.Titre)
        @Html.DisplayFor(m => m.Titre)
    </td>
    <td>
        @Html.LabelFor(m => m.Description)
        @Html.DisplayFor(m => m.Description)
    </td>
    <td>
        @Html.LabelFor(m => m.DateCloture)
        @Html.DisplayFor(m => m.DateCloture)
    </td>
</tr>

Sign up to request clarification or add additional context in comments.

Comments

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.