title: Update,Edit, Delete and import file. javascript. in VisualStudio using ASP:NET MVC C#
body: <p>I am a beginner in coding. I have been asked to make an application in VisualStudio using ASP.Net, MVC.</p>
  
  <p>I have created a view where you can display a table from the database. Now I have to be able to <em>Edit</em> the data in another view and in the same view.</p>
  
  <p>When I create a new view, I have this error when I try to run it:</p>
  
  <blockquote>
    <p>The parameters dictionary contains a null entry for parameter 'EmailId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Edit(Int32, System.String, System.String, System.String, System.String)' in 'MyMVCApplication.Controllers.EmailTemplateController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
    Parameter name: parameters </p>
  </blockquote>
  
  <p>I can not figure out what the problem is in the controller as I am just two months learning so I am still working on the basics.</p>
  
  <p>This is my code:</p>
  
  <p>Controller:</p>
  
  <pre><code>public ActionResult Edit (int EmailId, string userName, string title, string Email, string description)
  {          
      UpdateDataBase(EmailId, userName, title, Email, description);
      return View("EmailData");
  }
  
  [HttpPost]
  public ActionResult Edit(ModelTemplateEmail  EditEmailData)
  {       
      if (ModelState.IsValid)
      {                
          return RedirectToAction("EmailData");
      };
  
      return View(EditEmailData);
  }
  </code></pre>
  
  <p>view:</p>
  
  <pre><code>@using (Html.BeginForm("Edit", "EmailTemplate", new { Id = Model.EmailData }, FormMethod.Post, null))
  {
      @Html.AntiForgeryToken()
  
      &lt;div class="form-horizontal"&gt;
          &lt;h4&gt;ModelTemplateEmail&lt;/h4&gt;
          &lt;hr /&gt;
          @Html.ValidationSummary(true, "", new { @class = "text-danger" })
          &lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model.EmailId, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model.EmailId, new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model.EmailId, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model.userName, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model.userName, new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model.userName, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model.Email, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model.Email, new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model.Email, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model.Title, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model.Title, new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model.Title, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model.description, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model.description, new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model.description, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model.Url, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model.Url, new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model.Url, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
  
          @Html.HiddenFor(model =&gt; model.EmailData)
  
          &lt;div class="form-group"&gt;
              &lt;div class="col-md-offset-2 col-md-10"&gt;
                  &lt;input type="submit" value="Save" class="btn btn-default" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  }
  
  &lt;div&gt;
      @Html.ActionLink("Back to List", "EmailData")
  &lt;/div&gt;
  
  @section Scripts {
      @Scripts.Render("~/bundles/jqueryval")
  }
  
  </code></pre>