title: How to retrieve value from table row and use that value in modal pop up submit click in MVC application?
body: <p>I have Index view where I am displaying list of data in a table. On each row second column <code>Name</code> click, I have displayed a modal up where I have created <code>TextAreaFor</code> to insert some input and then on <code>submit</code> button click, the data should store in respective row in database table. I got stuck how to insert modal input value in respective row in database table.</p>
  
  <p>Please help me. Your help is highly appreciated.</p>
  
  <pre><code> public class MyClass
      {
        public int Id {get;set;}
        public string Name { get; set; }
        public string AddNote { get; set; }
      }
  </code></pre>
  
  <p>Home Controller</p>
  
  <pre><code>[ChildActionOnly]
          public PartialViewResult _pNote()
          {
           MyClass model = new MyClass();
           return PartialView("_pNote", model);
          }
  
        [ChildActionOnly]
          [HttpPost]
          public PartialViewResult _pNote(int Id)
          {
              MyClass model = new MyClass();
               model=submitrecord(Id);
              return PartialView("_pNote", model);
          }
  </code></pre>
  
  <p>Index View</p>
  
  <pre><code>               @model List&lt;Proj.xx.MyClass&gt;
                         &lt;table&gt;
                          &lt;tr &gt;
                              &lt;th&gt;
                                  @Html.DisplayName("Id")
                              &lt;/th&gt;
                              &lt;th&gt;
                                  @Html.DisplayName("Name")
                              &lt;/th&gt;                           
  
                          &lt;/tr&gt;
                          @foreach (var item in Model)
                         {
                          &lt;tr&gt;
                                 &lt;td&gt;
                                    @Html.DisplayFor(modelItem =&gt; item.Id)                                
                                  &lt;/td&gt;                           
  
                                  &lt;td&gt;
                             &lt;a data-toggle="modal" data-target="#AddNote"&gt;                                      
                                    @Html.DisplayFor(modelItem =&gt; item.Name)
                                  &lt;/a&gt;
  
                     &lt;/td&gt;     
  
                          &lt;/tr&gt;
                     }
  
                      &lt;/table&gt;
  @{ Html.RenderAction("_pNote"); }
  </code></pre>
  
  <p>_pNote Partial</p>
  
  <pre><code>@model Proj.xx.MyClass
  
  @using (Html.BeginForm("_pNote", "Home", FormMethod.Post, new { @Id = "form" }))
  {
      &lt;div class="modal fade" id="AddNote" role="dialog"&gt;
          &lt;div class="modal-dialog" role="document"&gt;
              &lt;div class="modal-content"&gt;
                  &lt;div class="modal-header"&gt;
                      &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
                          &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
                      &lt;/button&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-body"&gt;  
  
                      @Html.HiddenFor(m =&gt; m.Id)
                      @Html.TextAreaFor(m=&gt;m.AddNote)
                  &lt;/div&gt;
  
                  &lt;div class="modal-footer"&gt;
                      &lt;button type="button" class="btn btn-secondary" id="reset" data-dismiss="modal"&gt;Close&lt;/button&gt;
  
                      &lt;button type="button" data-assigned="@Model.Id" id="Submit" class="btn btn-primary"&gt;Submit&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  }
  </code></pre>
  
  <p>JQuery</p>
  
  <pre><code>$('#Submit').click(function () {
               debugger;
             var id=  $('#Id').val($(this).text());                
               var path = '@Url.Action("_pNote", "Home")?id=' + id;
               path= encodeURI(path);
           });
  </code></pre>