How to display two pages of the same Gridview side by side?

Asked

Viewed 399 times

2

I would like to know how to display two pages of the same GridView side by side, if possible keeping the pagination on both pages at the same time. For example, if I have a GridView in that way:

Num Produto   
--------------
1   Banana
2   Abacaxi
3   Morango
4   Castanha
5   Alface
6   Tomate
7   Cebola
8   Pimentão
9   Melão
10  Melancia
Páginas: (1) 2 3

He’d look like this:

Num Produto       Num Produto
-------------------------------
1   Banana        6   Tomate
2   Abacaxi       7   Cebola
3   Morango       8   Pimentão
4   Castanha      9   Melão
5   Alface        10  Melancia
       Páginas: (1) 2 3

The pagination would update the two parts of the GridView at the same time, as in the first case. If paging is not possible, display the GridView whole in two parts already solves the problem.

1 answer

1


With the component GridView would be more complicated. In this case, you can do this using server control DataList. In this component, we have the properties RepeatDirection defining the data display mode (Horizontal or Vertical) and property RepeatColumns (integer) that sets the number of columns for each repeat. In your case, you can set RepeateDirection for Vertical and RepeatColumns for 2and it will repeat the way you specified, example:

<asp:DataList ID="dataList1" runat="server" RepeatDirection="Vertical" RepeatColumns="2">
  <ItemTemplate>
     <asp:Label runat="server" ID="lblProduto" Text='<%# Eval("Produto") %>'></asp:Label> - 
     <asp:Label runat="server" ID="lblPreco"
            Text='<%# Eval("PrecoUnit", "{0:C}") %>' />
  </ItemTemplate>
</asp:DataList>

To make the pagination, you can implement the component DataPager, because different from the GridView, the DataList does not have native paging. With it you can define various forms of paging, such as próximo/anterior, numérica etc...

See more how to work with DataList in:

  • This is a good alternative. I didn’t know it was possible to use ItemTemplate with components other than GridView.

  • Yes, it is possible, also with the Repeater. See more on: http://msdn.microsoft.com/en-us/library/ms228214.ASPX

  • The only drawback is that it is not possible to use paging on these components, only in Gridview...

  • Yes, it is possible with the component DataPager.

Browser other questions tagged

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