List of DB clients on the program page in C#

Asked

Viewed 68 times

-1

My problem is this, I do not know how to make appear on the user screen a list with limit X of clients of a DB, I will try to put in topics for a better understanding

1 - The customer list should appear every 10
2 - When reached the 10 would have, a button or arrow to the next page
3 - I saw some tutorials with gridview, but that’s not what I’m looking for
4 - When they appear they should come as a linklabel
5 - When clicked the linklabel the client id must be passed to another form

I hope that’s possible, if someone can explain to me how to do I’m grateful. I don’t know if it makes a difference but I use Visual Studio 2010 professional, and I use sql server

  • Henry, if possible post what you’ve tried so far, it’s easier for people to help you.

  • I haven’t tried anything because I have no idea how to do this, I’m looking on youtube and forums to see if I can find something related

  • Do you want to do this in a web application right? You can already fetch customers in the database?

  • No, it’s a PC program even with no relation to any browser, and yes I can search in DB

1 answer

-1

Dude, from what I understand, you want me to show you a list of 10 users and then pass the page on that list, that’s it?

I made an example using Pagedlist. I’ll leave an example of how I managed to do.

In the controller I did like this: using Pagedlist;

    public ActionResult Index(int? pagina)
    {
        var ListaEventos = db.Objetos.Tolist();
        int PaginaTamanho = 4; //<<<<<Tamanho de objetos na pagina(no seu caso coloca 10)
        int paginaNumero = (pagina ?? 1);


        return View(ListaEventos.ToPagedList(paginaNumero, PaginaTamanho));

Already in html I just put this like this:

Page @(Model.Pagecount < Model.Pagenumber ? 0 : Model.Pagenumber)

@Model.PageCount

@if (Model.HasPreviousPage)
{
    @Html.ActionLink("<<", "Index", new { pagina = 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }, new { type = "button", @class = "btn btn-info", style = "background-color: #009688" })

    @Html.Raw(" ");

    @Html.ActionLink("< Previous", "Index", new { pagina = Model.PageNumber - 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter },new {type= "button",  @class = "btn btn-info", style = "background-color: #009688" })
}
else
{
    @:<button type="button" class="btn btn-info" style="background-color: #009688"><<</button>
    @Html.Raw(" ");
    @:<button type="button" class="btn btn-info" style="background-color: #009688">Previous</button>
}
@if (Model.HasNextPage)
{
    @Html.ActionLink("Next ", "Index", new { pagina = Model.PageNumber + 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter } , new { type = "button", @class = "btn btn-info" , style = "background-color: #009688" })
    @Html.Raw(" ");
    @Html.ActionLink(">>", "Index", new { pagina = Model.PageCount, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }, new { type = "button", @class = "btn btn-info", style = "background-color: #009688" })
}
else
{
    @:<button type="button" class="btn btn-info" style="background-color: #009688">Next</button>
    @Html.Raw(" ")
    @:<button type="button" class="btn btn-info" style="background-color: #009688">>></button>
}

I hope I’ve helped!

  • but ai will not open in a browser?

Browser other questions tagged

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