asp.net mvc - Cannot POST complex object from View to Controller -


so i've read many of questions , can't seem find correlation. have view model consists of model several collections of - guessed - more models:

public class feetemplateviewmodel     public property feesetup feesetupmodel             public property templateid integer     public property name string     public property companyid integer     public property groupid integer     public property users integer     public property createdate datetime     public property modified datetime     public property createdby string end class  public class feesetupmodel     <displayname("office id")>     property officeid() string     <displayname("office name")>     property officename() string     <displayname("current fees")>     property currentfees() ienumerable(of feeitemmodel)     <displayname("minimum preparer fee")>     public property minpfee decimal     public property availablefees list(of feelistitem)     public property customfees list(of customfee) end class 

when post controller view, feesetup null , can't determine why.

controller:

<httppost()> function edit(model feetemplateviewmodel) actionresult     modelstate.clear()     if string.isnullorempty(model.name)         modelstate.addmodelerror("name", "template name required")     end if     if not modelstate.isvalid         return view("edit", model)     end if     save(model)     return view("edit") end function 

modelstate error:

{"the parameter conversion type 'system.string' type 'proavalon.models.configuration.feesetupmodel' failed because no type converter can convert between these types."}

view:

@using html.beginform("edit", "feetemplate", nothing, formmethod.post, nothing) @<div>     @html.hiddenfor(function(m) m.feesetup)     @if model.templateid > 0         @<p><strong>last modified:</strong>@model.modified.tolocaltime</p>     end if      <div class="inputsection col-md-14" id="options">         <div class="row">             <div>                 @html.labelfor(function(m) m.name, "template name")                 @html.editorfor(function(m) m.name, "templatename")             </div>         </div>         @html.validationmessagefor(function(m) m.name)         <div style="height:50px;line-height:50px;">             <div id="status-bar" style="display:none">                 <span style="font-size:16px; margin-left:5px; font-weight:bold; color: #333;" />             </div>         </div>         <div class="clearfix" />         <div id="fee-grid-wrapper" style="min-height:500px;">             <table id="fee-grid" class="table table-striped table-condensed table-bordered table-fixed-header">                 <thead>                     <tr class="alert-info">                         <th style="border:none;vertical-align:top;text-transform:uppercase;">                             <strong>filter forms</strong>                         </th>                         <th style="border: none; vertical-align: top;" colspan="3">                             <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12" style="padding:0 5px">                                 <input name="filter" type="radio" checked="checked" data-filter="" /> forms                             </div>                             <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12" style="padding:0 5px">                                 <input name="filter" type="radio" data-filter="fd" /> federal forms <br />                                 <input name="filter" type="radio" id="state-forms" /> state forms                                 <div style="display:none" id="state-form-picker" class="state-picker">                                     @html.dropdownlistfor(function(m) i, proavalon.pagehelpers.stateselectlist)                                 </div>                             </div>                             <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12" style="padding:0 5px" id="search-target">                             </div>                         </th>                     </tr>                     <tr style="background:#eee">                         <th style="cursor:pointer">no.</th>                         <th style="cursor:pointer">fed/st</th>                         <th style="cursor:pointer">form/schedule name</th>                         <th style="cursor:pointer">amount</th>                     </tr>                 </thead>                 <tfoot>                     <tr style="background:#eee">                         <th>no.</th>                         <th>fed/st</th>                         <th>form/schedule name</th>                         <th style="min-width:300px">amount</th>                     </tr>                 </tfoot>                 <tbody>                     @if model.feesetup.availablefees isnot nothing                             each fee in model.feesetup.availablefees                                 @html.hiddenfor(function(m) fee)                         @code                             dim tmp proavalon.models.configuration.feeitemmodel = model.feesetup.currentfees.where(function(x) x.formname = fee.formname).firstordefault()                             dim amount = 0d                             if (tmp isnot nothing) amount = tmp.feeamount                             = + 1                             html.hiddenfor(function(m) tmp)                         end code                         @<tr data-id="@(fee.formname)">                             <td>@(i) </td>                             <td>@(iif(fee.formtype = "fd", fee.formtype, iif(fee.formtype = "bs", fee.formstate + "-bs", fee.formstate)))</td>                             <td>@(fee.formdesc)</td>                             <td style="min-width:300px">                                 <span style="display:none">@amount</span> @*to enable sorting*@                                 @html.textboxfor(function(m) amount)                                 @*@(new htmlstring("<span>" + _                             html.textbox("amount_" + fee.formname.tostring(), ctype(amount, decimal), _                             new {.class = "pull-left currency_input currencytb amount_" + fee.formname}).tohtmlstring() + _                             "<span id=""msg_" + fee.formname + """ style='display:none; line-height:35px;padding-left:10px;'></span></span>"))*@                             </td>                         </tr>                     next                 end if                 </tbody>             </table>         </div>     </div> </div> @<br /> @<div>     <hr />     <div class="float-right" style="margin-left: 20pt">         @html.submitbutton()     </div>     <div>         @html.cancelbutton("index", "feetemplate")     </div>     <div class="clear clearfix" /> </div> end using 

i'm going feel real jerk if 1 of looks @ , finds naming overlap, i've looked through several times , cannot determine cause.

to begin, list binding not work on this:

for each fee in model.feesetup.availablefees 

you'll need through using index:

for index integer = 0 model.feesetup.availablefees.length     @html.hiddenfor(function(m) m.feesetup.availablefees[index]) next 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -