-1
I have an edit controller, which receives a value from the bank and plays for view, and then I want with this view to play the values on the screen (basic test)...
However, even with my controller that takes to edit view by passing an object Subsidiary, it tells me which branch is void. Follows below my controller and my view:
public ActionResult Edita(string nome_filial)
{
Conexao conexao = new Conexao();
Filial filial = new Filial();
string comando = "SELECT A.FILIAL, B.VALOR_PROPRIEDADE FROM FILIAIS A " +
"LEFT JOIN PROP_FILIAIS B ON A.FILIAL = B.FILIAL AND B.PROPRIEDADE = '00814'" +
"WHERE A.FILIAL = @FILIAL";
var parametros = new Dictionary<string, object>
{
{"FILIAL", nome_filial}
};
var rows = conexao.ExecutaComandoComRetorno(comando, parametros);
foreach (var row in rows)
{
filial.filial = row["FILIAL"];
filial.estoque_max = row["VALOR_PROPRIEDADE"];
}
return View(filial);
}
[HttpPost]
public ActionResult Edita(Filial filial) {
return Content(filial.estoque_max.ToString() + filial.filial.ToString());
}
VIEW:
@model MaxEstoqueFiliais.Models.Filial
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Filial</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.filial, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.filial, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.filial, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.estoque_max, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.estoque_max, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.estoque_max, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Filial Class:
public class Filial
{
[DisplayName("Filial")]
public string filial { get; set; }
[DisplayName("Estoque Máximo")]
public string estoque_max { get; set; }
}
Why is getting null my affiliate object, being that I am passing it to the view?
Can anyone help me? I have done everything, I have done the same as other projects of mine and other projects are working, only this one that will not go at all. And it makes no sense!
– maiconfriedel
I don’t know if it can be, it’s an achism, but his property is called filical and the filial object, maybe he’s getting lost in it
– Barbetta
Add the class
Filial
to the question– Leandro Angelo
@Barbetta, you won’t believe it, but I reenomed the branch name in the class, and it worked! Pqp (facepalm)
– maiconfriedel