asp.net mvc - I have a list with objects, each object contains a list, each of these lists needs to become a DropDownList in a gridview -


i have list contains ~80 of following objects:

public class sourcemapping {     public int id { get; set; }     public string sourcewaarde { get; set; }     public string onderwerp { get; set; }     public string sourceid { get; set; }     public string applicatiedataid { get; set; }      [notmapped]     public string selectedvalue { get; set; }     [notmapped]     public ienumerable<selectlistitem> destinationoptionslist { get; set; } } 

each of these objects can see has ienumerable< selectlistitem > these options want display in table combobox (dropdownlist). way works should work:

    @model myproject.models.home.homeviewmodel      <table>     @foreach (var sourceentity in model.onderwerp.sourceentitieslist)     {         <tr>             <td>                 @sourceentity.sourcewaarde             </td>             <td>                 @html.dropdownlistfor(model => sourceentity.selectedvalue, sourceentity.destinationoptionslist)             </td>         </tr>     }     </table> 

in above view model.onderwerp.sourceentitieslist list contains sourcemapping objects.

the above view show table sourcewaardes, next dropdownlist right selected value.

now want use webgrid , can't seem find how transform above view in 1 uses webgrid. far have this:

    @model myproject.models.home.homeviewmodel          @{     webgrid webgrid = new webgrid(model.onderwerp.sourceentitieslist, cansort: false);        }      @webgrid.gethtml(mode: webgridpagermodes.all, tablestyle: "tranlist",             headerstyle: "", firsttext: "", lasttext: "",             columns: webgrid.columns(                    webgrid.column("sourcewaarde", header: "bron waarde"),                    webgrid.column(header: "doel waarde",                         format: (item) => @html.dropdownlistfor(model => model.selectedvalue,                             model.onderwerp.sourceentitieslist.destinationoptionslist))                    )) 

the problem in last row:

(item) => @html.dropdownlistfor(model => model.selectedvalue,                 model.onderwerp.sourceentitieslist.destinationoptionslist) 

the model.onderwerp.sourentitieslist.destinationoptionlist should refer last iterated object in webgrid. i'm pretty stuck right can welcome. found hard explain problem, if need more information i'll happy provide.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -