Filling table on same View MVC
I'm new to MVC, that's the first application the company asked me to develop.
I have a View containing some inputs about origin and destination points and a map. I send to my Controller to a route calculation API and I get the responses. Everything is fine until here.
After receiving the reponse from the API containing the the tolls list, I want to fill a table that it's in the same View as the inputs and the map.
The HTML of the table I'm trying to fill:
@model App.Models.RespViagem
<div class="result">
@if (Model != null && Model.Pedagios.Count > 0)
{
<table class="table table-hover" style="visibility: visible">
<caption>PEDÁGIOS</caption>
<tr>
<th>Número</th>
<th>Praça</th>
<th>Sentido</th>
<th>Endereço</th>
<th>Concessão</th>
<th>Telefone</th>
<th>Estado</th>
<th>Preço por eixo</th>
<th>Preço total</th>
</tr>
@foreach (var item in Model.Pedagios)
{
<tr>
<td></td>
<td>@item.Nome</td>
<td>@item.Sentido</td>
<td>@item.Endereco</td>
<td>@item.Concessao</td>
<td>@item.Fone</td>
<td>@item.Estado</td>
<td>@item.PrecoEixo</td>
<td>@item.Preco</td>
</tr>
}
</table>
}
</div>
And the controller that gets the response and send to the view:
public class HomeController : Controller
{
public ActionResult Index()
{
var rotas = new GPS();
ViewBag.Rotas = rotas.PegaTipoRota(false).Rows;
return View(TempData["Viagem"] as RespViagem);
}
[HttpPost]
public ActionResult Calcula(InfosViagem listaRota)
{
... Get the responses ...
//Store in a tempdata
TempData["Viagem"] = respViagem;
return RedirectToAction("Index");
}
}
I can see the foreach working and adding the data to the table, but when it's finished, the table doesn't appear in the browser.
c# html asp.net-mvc razor html-table
New contributor
vtrivellato is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
|
show 4 more comments
I'm new to MVC, that's the first application the company asked me to develop.
I have a View containing some inputs about origin and destination points and a map. I send to my Controller to a route calculation API and I get the responses. Everything is fine until here.
After receiving the reponse from the API containing the the tolls list, I want to fill a table that it's in the same View as the inputs and the map.
The HTML of the table I'm trying to fill:
@model App.Models.RespViagem
<div class="result">
@if (Model != null && Model.Pedagios.Count > 0)
{
<table class="table table-hover" style="visibility: visible">
<caption>PEDÁGIOS</caption>
<tr>
<th>Número</th>
<th>Praça</th>
<th>Sentido</th>
<th>Endereço</th>
<th>Concessão</th>
<th>Telefone</th>
<th>Estado</th>
<th>Preço por eixo</th>
<th>Preço total</th>
</tr>
@foreach (var item in Model.Pedagios)
{
<tr>
<td></td>
<td>@item.Nome</td>
<td>@item.Sentido</td>
<td>@item.Endereco</td>
<td>@item.Concessao</td>
<td>@item.Fone</td>
<td>@item.Estado</td>
<td>@item.PrecoEixo</td>
<td>@item.Preco</td>
</tr>
}
</table>
}
</div>
And the controller that gets the response and send to the view:
public class HomeController : Controller
{
public ActionResult Index()
{
var rotas = new GPS();
ViewBag.Rotas = rotas.PegaTipoRota(false).Rows;
return View(TempData["Viagem"] as RespViagem);
}
[HttpPost]
public ActionResult Calcula(InfosViagem listaRota)
{
... Get the responses ...
//Store in a tempdata
TempData["Viagem"] = respViagem;
return RedirectToAction("Index");
}
}
I can see the foreach working and adding the data to the table, but when it's finished, the table doesn't appear in the browser.
c# html asp.net-mvc razor html-table
New contributor
vtrivellato is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
So? Did you inspect the DOM in your browser? Look at the CSS applied to your table? Verify the markup looks as expected? Look for errors in your JavaScript console?
– mason
Dec 27 '18 at 14:57
Why you don't just pass an instance to the view instead of using tempdata. You can define model in your view page with @model and make a foreach loop.
– Armin Torkashvand
Dec 27 '18 at 14:58
@Armin Torkashvand. Actually I'm using a@model, just forgot to put it in the code.
– vtrivellato
Dec 27 '18 at 15:04
@mason. Checked my browser console and nothing is being shown there. The table works fine if I add something "manually" to it in the code, but nothing happens when the table is filled with the model items.
– vtrivellato
Dec 27 '18 at 15:10
You didn't answer the other questions in my initial comment.
– mason
Dec 27 '18 at 15:11
|
show 4 more comments
I'm new to MVC, that's the first application the company asked me to develop.
I have a View containing some inputs about origin and destination points and a map. I send to my Controller to a route calculation API and I get the responses. Everything is fine until here.
After receiving the reponse from the API containing the the tolls list, I want to fill a table that it's in the same View as the inputs and the map.
The HTML of the table I'm trying to fill:
@model App.Models.RespViagem
<div class="result">
@if (Model != null && Model.Pedagios.Count > 0)
{
<table class="table table-hover" style="visibility: visible">
<caption>PEDÁGIOS</caption>
<tr>
<th>Número</th>
<th>Praça</th>
<th>Sentido</th>
<th>Endereço</th>
<th>Concessão</th>
<th>Telefone</th>
<th>Estado</th>
<th>Preço por eixo</th>
<th>Preço total</th>
</tr>
@foreach (var item in Model.Pedagios)
{
<tr>
<td></td>
<td>@item.Nome</td>
<td>@item.Sentido</td>
<td>@item.Endereco</td>
<td>@item.Concessao</td>
<td>@item.Fone</td>
<td>@item.Estado</td>
<td>@item.PrecoEixo</td>
<td>@item.Preco</td>
</tr>
}
</table>
}
</div>
And the controller that gets the response and send to the view:
public class HomeController : Controller
{
public ActionResult Index()
{
var rotas = new GPS();
ViewBag.Rotas = rotas.PegaTipoRota(false).Rows;
return View(TempData["Viagem"] as RespViagem);
}
[HttpPost]
public ActionResult Calcula(InfosViagem listaRota)
{
... Get the responses ...
//Store in a tempdata
TempData["Viagem"] = respViagem;
return RedirectToAction("Index");
}
}
I can see the foreach working and adding the data to the table, but when it's finished, the table doesn't appear in the browser.
c# html asp.net-mvc razor html-table
New contributor
vtrivellato is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I'm new to MVC, that's the first application the company asked me to develop.
I have a View containing some inputs about origin and destination points and a map. I send to my Controller to a route calculation API and I get the responses. Everything is fine until here.
After receiving the reponse from the API containing the the tolls list, I want to fill a table that it's in the same View as the inputs and the map.
The HTML of the table I'm trying to fill:
@model App.Models.RespViagem
<div class="result">
@if (Model != null && Model.Pedagios.Count > 0)
{
<table class="table table-hover" style="visibility: visible">
<caption>PEDÁGIOS</caption>
<tr>
<th>Número</th>
<th>Praça</th>
<th>Sentido</th>
<th>Endereço</th>
<th>Concessão</th>
<th>Telefone</th>
<th>Estado</th>
<th>Preço por eixo</th>
<th>Preço total</th>
</tr>
@foreach (var item in Model.Pedagios)
{
<tr>
<td></td>
<td>@item.Nome</td>
<td>@item.Sentido</td>
<td>@item.Endereco</td>
<td>@item.Concessao</td>
<td>@item.Fone</td>
<td>@item.Estado</td>
<td>@item.PrecoEixo</td>
<td>@item.Preco</td>
</tr>
}
</table>
}
</div>
And the controller that gets the response and send to the view:
public class HomeController : Controller
{
public ActionResult Index()
{
var rotas = new GPS();
ViewBag.Rotas = rotas.PegaTipoRota(false).Rows;
return View(TempData["Viagem"] as RespViagem);
}
[HttpPost]
public ActionResult Calcula(InfosViagem listaRota)
{
... Get the responses ...
//Store in a tempdata
TempData["Viagem"] = respViagem;
return RedirectToAction("Index");
}
}
I can see the foreach working and adding the data to the table, but when it's finished, the table doesn't appear in the browser.
c# html asp.net-mvc razor html-table
c# html asp.net-mvc razor html-table
New contributor
vtrivellato is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
vtrivellato is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited Dec 27 '18 at 15:05
New contributor
vtrivellato is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Dec 27 '18 at 14:52
vtrivellato
42
42
New contributor
vtrivellato is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
vtrivellato is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
vtrivellato is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
So? Did you inspect the DOM in your browser? Look at the CSS applied to your table? Verify the markup looks as expected? Look for errors in your JavaScript console?
– mason
Dec 27 '18 at 14:57
Why you don't just pass an instance to the view instead of using tempdata. You can define model in your view page with @model and make a foreach loop.
– Armin Torkashvand
Dec 27 '18 at 14:58
@Armin Torkashvand. Actually I'm using a@model, just forgot to put it in the code.
– vtrivellato
Dec 27 '18 at 15:04
@mason. Checked my browser console and nothing is being shown there. The table works fine if I add something "manually" to it in the code, but nothing happens when the table is filled with the model items.
– vtrivellato
Dec 27 '18 at 15:10
You didn't answer the other questions in my initial comment.
– mason
Dec 27 '18 at 15:11
|
show 4 more comments
2
So? Did you inspect the DOM in your browser? Look at the CSS applied to your table? Verify the markup looks as expected? Look for errors in your JavaScript console?
– mason
Dec 27 '18 at 14:57
Why you don't just pass an instance to the view instead of using tempdata. You can define model in your view page with @model and make a foreach loop.
– Armin Torkashvand
Dec 27 '18 at 14:58
@Armin Torkashvand. Actually I'm using a@model, just forgot to put it in the code.
– vtrivellato
Dec 27 '18 at 15:04
@mason. Checked my browser console and nothing is being shown there. The table works fine if I add something "manually" to it in the code, but nothing happens when the table is filled with the model items.
– vtrivellato
Dec 27 '18 at 15:10
You didn't answer the other questions in my initial comment.
– mason
Dec 27 '18 at 15:11
2
2
So? Did you inspect the DOM in your browser? Look at the CSS applied to your table? Verify the markup looks as expected? Look for errors in your JavaScript console?
– mason
Dec 27 '18 at 14:57
So? Did you inspect the DOM in your browser? Look at the CSS applied to your table? Verify the markup looks as expected? Look for errors in your JavaScript console?
– mason
Dec 27 '18 at 14:57
Why you don't just pass an instance to the view instead of using tempdata. You can define model in your view page with @model and make a foreach loop.
– Armin Torkashvand
Dec 27 '18 at 14:58
Why you don't just pass an instance to the view instead of using tempdata. You can define model in your view page with @model and make a foreach loop.
– Armin Torkashvand
Dec 27 '18 at 14:58
@Armin Torkashvand. Actually I'm using a
@model, just forgot to put it in the code.– vtrivellato
Dec 27 '18 at 15:04
@Armin Torkashvand. Actually I'm using a
@model, just forgot to put it in the code.– vtrivellato
Dec 27 '18 at 15:04
@mason. Checked my browser console and nothing is being shown there. The table works fine if I add something "manually" to it in the code, but nothing happens when the table is filled with the model items.
– vtrivellato
Dec 27 '18 at 15:10
@mason. Checked my browser console and nothing is being shown there. The table works fine if I add something "manually" to it in the code, but nothing happens when the table is filled with the model items.
– vtrivellato
Dec 27 '18 at 15:10
You didn't answer the other questions in my initial comment.
– mason
Dec 27 '18 at 15:11
You didn't answer the other questions in my initial comment.
– mason
Dec 27 '18 at 15:11
|
show 4 more comments
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
vtrivellato is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53946916%2ffilling-table-on-same-view-mvc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
vtrivellato is a new contributor. Be nice, and check out our Code of Conduct.
vtrivellato is a new contributor. Be nice, and check out our Code of Conduct.
vtrivellato is a new contributor. Be nice, and check out our Code of Conduct.
vtrivellato is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53946916%2ffilling-table-on-same-view-mvc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
So? Did you inspect the DOM in your browser? Look at the CSS applied to your table? Verify the markup looks as expected? Look for errors in your JavaScript console?
– mason
Dec 27 '18 at 14:57
Why you don't just pass an instance to the view instead of using tempdata. You can define model in your view page with @model and make a foreach loop.
– Armin Torkashvand
Dec 27 '18 at 14:58
@Armin Torkashvand. Actually I'm using a
@model, just forgot to put it in the code.– vtrivellato
Dec 27 '18 at 15:04
@mason. Checked my browser console and nothing is being shown there. The table works fine if I add something "manually" to it in the code, but nothing happens when the table is filled with the model items.
– vtrivellato
Dec 27 '18 at 15:10
You didn't answer the other questions in my initial comment.
– mason
Dec 27 '18 at 15:11