You can do in the scope of an Action that receives the template of your submitted fomulário
[HttpPost]
public ActionResult Edit([Bind(Exclude="Banco")]CompanyDto model)
{
// ...
}
You can also describe the property in the scope of your model since when this way will be influenced throughout the
application and not only in the Action being used.
[Bind(Exclude="Propriedade_1,Propriedade_2,Propriedade_3")]
public class CompanyDto
{
public int Id { get; set; }
public string Propriedade_1 { get; set; }
public string Propriedade_2 { get; set; }
public string Propriedade_3 { get; set; }
// ...
}
You can also filter a property of an example model object
public class CompanyDto
{
public int Id { get; set; }
[Exclude]
public string Propriedade_1 { get; set; }
public string Propriedade_2 { get; set; }
public string Propriedade_3 { get; set; }
// ...
}
Another way to check is to put a breakpoint in the Action that receives the data and before that in the browser price F12 and check the value of the item that has the 'Selected' property of your dropdown before you submit the form, for Action.
Where are you checking this Modelstate.Isvalid?
– PauloHDSousa
in the controller, in the action that persists the information in the database.
– Edmar Munhoz
Please post exactly what your Modelstate is returning as a validation error.
– Thiago Lunardi
You are returning this message: "The value '1' is invalid." 1 is the Id of the selected database.
– Edmar Munhoz
It has to put the code of the controller also?
– PauloHDSousa
Take advantage and put the Model code too
– Joel Ramos Michaliszen