c# - Send Data from View to Controller in MVC -


i have view renders data viewdata shown below table.

as can see there button each row.

i want send row data controller corresponding button when clicked.

how achieve this?

please suggestion , best methodologies implement this.

i tried using knockout bind data , post controller posted in how bind data razor knockout? did not work nothing gets binded.

view

@{     var userwrinfo = (list<infoentity>)viewdata["userwrinfo"];     var userowner = (list<string>)viewdata["userowner"];      <table class="table table-bordered">         <thead>             <tr>                 <th ><b>status</b></th>                 <th ><b>appropriation</b></th>                 <th ><b>prioritydate</b></th>                 <th ><b>location</b></th>                 <th ><b>source</b></th>                 <th ><b>owner</b></th>                 <th ><b>use</b></th>                 <th ><b>startedby</b></th>                 <th ><b>requiredreporting</b></th>             </tr>         </thead>          <tbody>             @for (int = 0; < userwrinfo.count; i++)             {                 <tr>                     <td><button type="submit" class="btn btn-primary">start</button></td>                     <td> @userwrinfo[i].appropriationnumber</td>                     <td> @userwrinfo[i].prioritydate.tostring("mm/dd/yyyy")</td>                     <td> @userwrinfo[i].sect @userwrinfo[i].township @userwrinfo[i].range@userwrinfo[i].rangedirectionid</td>                     <td> @userwrinfo[i].source</td>                     @if (userwrinfo.count == userowner.count)                     {                         <td> @userowner[i].tostring()</td>                     }                     else                     {                         <td ></td>                     }                      <td> @userwrinfo[i].usedescription</td>                     <td></td>                     <td> @userwrinfo[i].isannualreportrequired</td>                 </tr>              }          </tbody>     </table> } 

try make way

<tbody>      @for (int = 0; < userwrinfo.count; i++) {     <form name="form_@i" method="post" action="controller/action">         <tr>             <td>                 <input type="hidden" name="@userwrinfo[i].appropriationnumber">@*repeate each attribute*@             </td>             <td><button type="submit" class="btn btn-primary">start</button></td>             <td> @userwrinfo[i].appropriationnumber</td>             <td> @userwrinfo[i].prioritydate.tostring("mm/dd/yyyy")</td>             <td> @userwrinfo[i].sect @userwrinfo[i].township @userwrinfo[i].range@userwrinfo[i].rangedirectionid</td>             <td> @userwrinfo[i].source</td>             @if (userwrinfo.count == userowner.count)             {                 <td> @userowner[i].tostring()</td>             }             else             {                 <td></td>             }              <td> @userwrinfo[i].usedescription</td>             <td></td>             <td> @userwrinfo[i].isannualreportrequired</td>         </tr>     </form> }  </tbody> 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -