开发者

Some fields are binding on postback some don't

开发者 https://www.devze.com 2023-01-14 18:30 出处:网络
I have a view containing a number of fields <div class=\"editor-label\"> <label for=\"Supplier\">Supplier</label>

I have a view containing a number of fields

<div class="editor-label">
    <label for="Supplier">Supplier</label>
</div>

<div class="editor-field">    
    <input id="S开发者_高级运维upplier" name="Supplier" type="text" value="Swifts Antiference Division Ltd" />
    <input id="SupplierId" name="SupplierId" type="hidden" value="1" />

</div>

<div class="editor-label">
    <label for="Scheme_Group">Group</label>
</div>
<div class="editor-field">    
    <select id="Scheme_Group_Id" name="Scheme.Group.Id"><option value="">Select group</option>
<option value="3">Gels</option>

<option value="2">Gloves</option>
<option selected="selected" value="1">Needles</option>
<option value="4">Soap</option>
</select> 

The problem I am having is when the form these fields are contained within is submitted to teh controler action only some of the values are received by the action. The Supplier and SupplierId fields work as expected but the "Scheme_Group_Id" is never populated.


You should also post how your action is declared and what type are you passing to the view.

Please check the binding in the action parameters, something like this :

public void Edit([Bind(Prefix = "ClassName")]string fieldName){ ...action code...}

More information in here MSDN

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号