tyczj
tyczj

Reputation: 73721

Show listview items vertically not horizontally

This is probably an dumb question but I have a ListView that displays data all in one row like this

Name Address Phone

what I want is to display the data vertically like this

Name
Address
Phone

what do I need to change to accomplish this?

<asp:ListView ID="ListView1" runat="server" >
            <ItemTemplate>
                    <tr id="tbl1" runat="server">
                        <td><%# Eval("name")%></td>
                        <td><%# Eval("address")%></td>
                        <td><%# Eval("phone")%></td>
                    </tr>
                </ItemTemplate>
            <LayoutTemplate>
                    <table id="tbl1" runat="server">
                        <tr id="tr1" runat="server">
                            <td id="td1" runat="server">name</td> 
                        </tr>
                        <tr id="tr2" runat="server">
                            <td id="td2" runat="server">address</td>
                        </tr>
                        <tr id="tr3" runat="server">
                            <td id="td3" runat="server">phone</td>
                        </tr>
                        <tr id="ItemPlaceholder" runat="server">  
                        </tr>
                    </table>
                </LayoutTemplate>
        </asp:ListView>

Upvotes: 1

Views: 3010

Answers (1)

IrishChieftain
IrishChieftain

Reputation: 15253

<asp:ListView ID="ListView1" runat="server" >
    <LayoutTemplate>
        <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
    </LayoutTemplate>
    <ItemTemplate>
        <table>
            <tr>
                <td><%# Eval("name") %></td> 
            </tr>
            <tr>
                <td><%# Eval("address") %></td>
            </tr>
            <tr>
                <td><%# Eval("phone") %></td>
            </tr>
        </table>
    </ItemTemplate>
</asp:ListView>

Upvotes: 2

Related Questions