Solved

change listview layout

Posted on 2011-09-21
4
568 Views
Last Modified: 2012-12-14
hi i load some data on one listview but the data shows like this:
that the layout we have:

1          2          3          4
5          6          7          8
9         10        11

but i want this one:

1          4          7      10
2          5          8      11
3          6          9

any suggestion?
0
Comment
Question by:rafaelrgl
4 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 300 total points
Comment Utility
It sounds like you are looking for something like this:

Repeating ListView GroupTemplate Vertically
http://forums.asp.net/p/1364813/2830987.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ListViewVertical.aspx.cs"
    Inherits="ListViewVertical" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>ListView vertical Repeat demo</title>
    <style type="text/css">
        .header
        {
            clear: both;
            width: 100%;
            text-align: center;
            border: 1px solid #ccc;
        }
        .item
        {
            clear: both;
            border: 1px Blue solid;
            width: 100%;
        }
        .group
        {
            /* i used 200px ,because the main layout width is 600px , and the width for each group is 200px.*/
            width: 200px;
            border: 1px red solid;
            float: left;
            margin: 3px;
            padding: 2px;
        }
        .mainLayout
        {
            width: 640px;
            border: yellow 2px solid;
            padding: 2px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ListView ID="ListView1" GroupItemCount="3" runat="server" DataSourceID="ObjectDataSource1">
            <LayoutTemplate>
                <div runat="server" id="Products" class="mainLayout">
                    <div id="Tr1" runat="server" class="header">
                        PRODUCTS LIST
                    </div>
                    <div runat="server" id="groupPlaceholder">
                    </div>
                </div>
            </LayoutTemplate>
            <GroupTemplate>
                <div runat="server" id="ProductsGroup" class="group">
                    <asp:PlaceHolder runat="server" ID="itemPlaceholder" />
                </div>
            </GroupTemplate>
            <GroupSeparatorTemplate>
            </GroupSeparatorTemplate>
            <ItemTemplate>
                <div id="Td1" align="center" runat="server" class="item">
                    <asp:Label ID="Label1" runat="server" Text='<%#Eval("ProductId","ProductId: {0}") %>' /><br />
                    <asp:Label ID="Label2" runat="server" Text='<%#Eval("Name","Name: {0}") %>' /><br />
                </div>
            </ItemTemplate>
            <ItemSeparatorTemplate>
                <br />
            </ItemSeparatorTemplate>
        </asp:ListView>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="GetAll" TypeName="Product">
            <SelectParameters>
                <asp:Parameter Type="Int32" Name="NumnerOfDummyProducts" DefaultValue="7" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </div>
 
    </form>
</body>
</html>

Open in new window

0
 
LVL 4

Assisted Solution

by:guramrit
guramrit earned 200 total points
Comment Utility
Check following code on any page.

 
<style type="text/css">
        .item
        {
            clear: both;
            width: 100%;
        }
        .group
        {
            float: left;
            margin: 3px;
            padding: 2px;
        }
    </style>

    <asp:ListView ID="ListView1" GroupItemCount="3" runat="server" DataSourceID="ObjectDataSource1">
        <LayoutTemplate>
            <div runat="server" id="Products" class="mainLayout">
                <div runat="server" id="groupPlaceholder">
                </div>
            </div>
        </LayoutTemplate>
        <GroupTemplate>
            <div runat="server" id="ProductsGroup" class="group">
                <asp:PlaceHolder runat="server" ID="itemPlaceholder" />
            </div>
        </GroupTemplate>
        <GroupSeparatorTemplate>
        </GroupSeparatorTemplate>
        <ItemTemplate>
            <div id="Td1" align="center" runat="server" class="item">
                <asp:Label ID="Label1" runat="server" Text='<%# Container.DataItem %>' />
            </div>
        </ItemTemplate>
    </asp:ListView>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
        SelectMethod="Range" TypeName="System.Linq.Enumerable">
        <SelectParameters>
            <asp:Parameter Name="start" DefaultValue="1" />
            <asp:Parameter Name="count" DefaultValue="11" />
        </SelectParameters>
    </asp:ObjectDataSource>

Open in new window

0
 
LVL 1

Author Closing Comment

by:rafaelrgl
Comment Utility
thanks a lots for this.
0
 

Expert Comment

by:simtouch
Comment Utility
This does not even work did you not even check your code?
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now