This question is locked. New answers and comments are not allowed.
Hello,
i have the following class structure:
ContingentType is shown in a DropDownList. How can i bind this value inside the update method?
The Key in the FormCollection is Contingent.ContingentType. But the ModelBinder won't bind this value.
Regards,
Timo
i have the following class structure:
public
class
PhysicianGridViewModel : PersonViewModel
{
public
PhysicianGridViewModel() {}
public
PhysicianGridViewModel( Physician physician ) :
base
( physician )
{
this
.Contingent =
new
ContingentViewModel(
new
Contingent { ContingentType =
new
ContingentType { ContingentTypeId = 1 } } );
}
public
int
ProjectId {
get
;
set
; }
public
ContingentViewModel Contingent {
get
;
set
; }
}
[Bind( Exclude =
"ContingentType"
)]
public
class
ContingentViewModel
{
public
ContingentViewModel() {}
public
ContingentViewModel( Contingent contingent )
{
this
.ContingentId = contingent.ContingentId;
this
.ContingentType =
new
ContingentTypeViewModel( contingent.ContingentType );
}
[ScaffoldColumn(
false
)]
public
int
ContingentId {
get
;
set
; }
[UIHint(
"ContingentType"
)]
public
ContingentTypeViewModel ContingentType {
get
;
set
; }
// ...
}
public
class
ContingentTypeViewModel
{
public
ContingentTypeViewModel() { }
public
ContingentTypeViewModel( ContingentType contingentType )
{
this
.ContingentTypeId = contingentType.ContingentTypeId;
this
.TypeName = contingentType.TypeName;
}
public
int
ContingentTypeId {
get
;
set
; }
public
string
TypeName {
get
;
set
; }
}
ContingentType is shown in a DropDownList. How can i bind this value inside the update method?
The Key in the FormCollection is Contingent.ContingentType. But the ModelBinder won't bind this value.
[GridAction( EnableCustomBinding =
true
)]
[HttpPost]
public
ActionResult _Update( GridCommand command, PhysicianGridViewModel model,
int
? contingent_ContingentType
/* the value from dropdownlist */
)
{
var t = Request.Form[
"Contingent.ContingentType"
];
// this is the value
return
View();
}
Regards,
Timo