2
I’m building an administrative application, and in this application I have a message page. I am currently bringing the last 20 messages.
I already have the screen ready to receive this messages, but my problem is in making the logic of the button that show the next 20 messages, and so consecutively.
//Mensagens Enviadas
List<Mensagem> mensagens = this.mensagemServico.GetMany(l => l.LojaId == loja.LojaId && l.OrigemId != 0).OrderByDescending(l => l.DataEnvio).Take(20).ToList();
mensagemModel.Mensagens = mensagens;
return View(mensagemModel);
Basically this is my routine: it takes the last 20 messages sorted by date, and according to origin (Client Origin == 0)
What I’d like to do is when I click "Next" he brings the next 20.
I had the initial idea to store in a variable of model (I have a MensagemModel
to return the value to the View) the amount already brought from Messages, or current page to be able to have this control.
I’m a beginner so I have doubts how to pass some information between Views, as an example, Models, and how a pagination should be made.
If anyone can give me a hand, even if it is about the logic that should be followed to make this paging, sorry to ask this kind of question but I do not want this paging to get bad so I wanted a help from you, thank you.
Cool your reply, I will check this method too, thank you very much for the attention.
– William Cézar
X.PagedList.Mvc is better than Skip?
– Marco Souza
Yes, so much so that it has controls also for the View.
– Leonel Sanches da Silva
+1, did not know this.
– Marco Souza