How to return the result of a query and assign to a textbox in asp.net mvc?
The "Type" is a Textbox from another screen, how can I record it and pass it as a parameter to the query?
This method that I created the breakpoint does not fall because there is already a method that returns to that view.
I've tried the following so far:
Data access class:
public BoletoModel IRPJ(string Tipo)
{
StringBuilder qryIRPS = new StringBuilder();
qryIRPS.Append("Select Descricao1 ");
qryIRPS.Append("from TiposNfsApp where ");
qryIRPS.Append(" Tipo = '" + Tipo + "'");
DadosNfsApp objDados = new DadosNfsApp();
BoletoModel bm = new BoletoModel();
DataTable dt = new DataTable();
dt = objDados.RetornarDataSet(qryIRPS.ToString()).Tables[0];
bm.IRPJ = dt.Rows[0]["Descricao1"].ToString().Trim();
return bm;
}
Controller:
public ActionResult RetornarIRPJ(string Tipo)
{
BoletoRepositorio br = new BoletoRepositorio();
BoletoModel bm = new BoletoModel();
bm.IRPJ = br.IRPJ(Tipo).ToString();
return View("Detalhes");
}
Existing method that returns to the View:
public ActionResult Detalhes(string Fatura)
{
var model = RetornarItemList(Fatura);
return PartialView(model);
}
View:
<label>
@Html.DisplayNameFor(model => model.IRPJ) :
@Html.TextBoxFor(model => model.IRPJ, new {@class = "form-control form-control-custom", style="width:60px"})
</label>