How to make GridView multicolumn in Asp.Net

痴心易碎 提交于 2020-01-06 06:10:47

问题


My GridView in only single column, how can I make it multicolumn?

There isn't an option to set column number in GridView properties.

Update :


回答1:


Because it can be difficult to get a table with 4 columns in a Repeater, here a little example.

<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>



回答2:


You cannot display GridView rows horizontally. A gridview is essentially an html table with each record displayed as new table row. You can try using a ListView or a Repeater to accomplish what you're trying to do.



来源:https://stackoverflow.com/questions/45511605/how-to-make-gridview-multicolumn-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!