asp.net mvc - How to display list items in view passed from the controller ? -


i developing mvc app.

i want create list in controller , pass view.

i have written method in controller dont know how call form view , display value return.

method in controller.

public list<invoice> getinvoicelist(int pid)         {             list<invoice> invoices = new list<invoice>();                       var invoicelist = (from in db.invoices                           i.paymentadviceid == pid                            select i);             invoices = invoicelist.tolist();              return (invoices);         } 

view code

  <div class="row-fluid">         <table class="table table-striped table-hover">             <thead>                 <tr>                     <th>advice no                   </th>                     <th>                      invoices                     </th>                </tr>             </thead>               @foreach (var item in model)             {                 <tbody>                     <tr>                         <td>                             @html.displayfor(modelitem => item.adviceno)                         </td>                         wan call controller method getinvoicelist here ,                        want display list items here...                          <td>                       </tr>                 </tbody> 

add partialview project has it's model set list<invoice>

then modify code:

    public partialviewresult getinvoicelist(int pid)     {         list<invoice> invoices = new list<invoice>();                   var invoicelist = (from in db.invoices                       i.paymentadviceid == pid                        select i);         invoices = invoicelist.tolist();          return partialview("partialviewname", invoices);     } 

in other view:

    <tr>         <td>             @html.displayfor(modelitem => item.adviceno)         </td>         <td> @html.action("getinvoicelist", new {pid = item.id})</td>     </tr> 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -