Include Dynamic Table in Viewbag

Asked

Viewed 51 times

0

I include the table data dynamically in AJAX, and it works perfectly to include in the table, what happens is, now I need the table data in the controller, and for using . NET CORE, I CAN’T GET THE DATA THROUGH JSON. How can I put Viewbag to receive data from my table, and use it in control ? Here is the form I include in the table:

  if (data.resultado) {
                $("#tablepesquisaprodutos").append("<tr class='item'>"
                    + "<td>" + CodigoProduto + "</td>"
                    + "<td>" + DescricaoProduto + "</td>"
                    + "<td>" + Qtd + "</td>"
                    + "<td>" + PrecoCusto + "</td>"
                    + "<td>" + DescontoP + "</td>"
                    + "<td>" + DescontoV + "</td>"
                    + "<td>" + Total.toFixed(2).replace(".", ",") + "</td>"
                    + "<td>" + ICMS + "</td>"
                    + "<td>" + AliquotaICMS.replace(".", ",") + "</td>"
                    + "<td>" + vICMS.toFixed(2).replace(".", ",") + "</td>"
                    + "<td>" + ISS.replace(".", ",") + "</td>"
                    + "<td>" + vISS.toFixed(2).replace(".", ",") + "</td>"
                    + "<td>" + IPI.replace(".", ",") + "</td>"
                    + "<td>" + vIPI.toFixed(2).replace(".", ",") + "</td>"
                    + "<td align='right'>" +
                    "<a class='link-excluir' data-id=" + CodigoProduto + " href='#' title='Excluir'><i class='fa fa-trash-o fa-lg'></i></a>"
                    + "</td>"
                    + "<td><div style='visibility: hidden;'>" + QtdFalta + "</div></td>"
                    + "<td><div style='visibility: hidden;'>" + ProdutoID + "</div></td>"
                    + "</tr>")
                getTotal();
                $("#produtoid").val("");
                $("#idproduto").val("");
                $("#qtd").val("");
                $("#precocusto").val("");
                $("#descontov").val("");
                $("#descontop").val("");
                $("#icms").val("");
                $("#aliquotaicms").html("");
                $("#ipi").val("");
                $("#iss").val("");
                $("#dataentrega").val("");
                $("#descricaoproduto").html("");
            }
  • Hi Mariana, I haven’t had the opportunity to work with . net core, but I believe that maybe this link can help you trigger your controller through ajax to transmit this data. Follow the link: https://liftcodeplay.com/2017/02/14/using-asp-net-core-and-jquery-to-call-methods-via-ajax/

  • @Sérgiolopes unfortunately did not help, but thanks anyway.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.