1
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, as I can record it and play it as a parameter for the query ?
This method that I created breakpoint does not fall, because there is already a method that returns to this view.
I’ve tried the following so far:
Class of data access:
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>
						
didn’t work. : S
– AndreeH
So, what mistake are you making? Or what problem are you having?~
– CesarMiguel
I tried this way you spoke and returned in the textbox a line of view code.
– AndreeH
You did the first method then, right? Erase the
(string)in the view– CesarMiguel
It sucks, he tells to do a cast that was in the case what I took and still doesn’t work ..
– AndreeH
Try to give me more details
– CesarMiguel
I forgot the "txtTitle", in the case put with the name of my field but still, is taking the name of the model.
– AndreeH