如何在Asp.Net中制作GridView多列

时间:2017-08-04 16:27:59

标签: asp.net gridview multiple-columns

我的GridView只在单列中,如何才能使其成为多列?

在GridView属性中没有设置列号的选项。

更新:

The GridView I have

2 个答案:

答案 0 :(得分:1)

因为在Repeater中获取一个包含4列的表可能很困难,这里有一个小例子。

<table border="1">
    <tr>
        <asp:Repeater ID="Repeater1" runat="server">
            <ItemTemplate>
                <%# Container.ItemIndex %4 == 0 && Container.ItemIndex > 0 ? "</tr><tr>" : "" %>
                <td><%# Eval("column") %></td>
            </ItemTemplate>
        </asp:Repeater>
    </tr>
</table>

答案 1 :(得分:0)

您无法水平显示GridView行。 gridview本质上是一个html表,每个记录显示为新的表行。 您可以尝试使用ListView或Repeater来完成您尝试执行的操作。