Mar 09, 2012, 9:14 AM
[CLOSED] Model Binding POSTed combobox values
Hi,
I'm using model binding to automatically map form POST values into my object. This works perfectly, except when comboxes are submitted. They provide an 'xxxxxx_value' key which is the actual ValueField I need to capture. When I bind (using default MVC modelbinder), it doesn't use this _value property; instead (I presume) using the name property I specify, which is a string - and therefore returns 0 in my bound object.
eg:
I'm using model binding to automatically map form POST values into my object. This works perfectly, except when comboxes are submitted. They provide an 'xxxxxx_value' key which is the actual ValueField I need to capture. When I bind (using default MVC modelbinder), it doesn't use this _value property; instead (I presume) using the name property I specify, which is a string - and therefore returns 0 in my bound object.
eg:
<ext:ComboBox ID="cboActionFunction" runat="server" FieldLabel="Function" LabelAlign="Right"
StoreID="storeActionFunctions" DisplayField="ActionFunctionTitle" ValueField="Id"
DataIndex="ActionFunctionId" AllowBlank="false" X="5" Y="5" Width="200" ForceSelection="true"
SelectOnFocus="true" Name="ActionFunctionId" EmptyText="Set function"
ListWidth="150" Mode="Local">
Controller: public ActionResult SaveAction(Models.Action act, int? hitlistId, int? actionId) {
....
}
The act object looks great, except combo values equal 0, as the _value property is not picked up, the DisplayField part is instead: ActionForId 0 int
ActionFunctionId 0 int
ActionStatusId 0 int
ActionSubject "A test subject" string
ActionTypeId 0 int
Apologies if this is more my misunderstanding of the MVC function; I'm not sure if it's an ext.net quirk or not.
Last edited by Daniil; Mar 13, 2012 at 5:32 PM.
Reason: [CLOSED]