这些列在asp:Repeater中混乱

时间:2013-11-20 09:40:51

标签: c# asp.net

我有这个转发器我得到这个...........我想要4列而不是5或6,具体取决于浏览器大小........谢谢..

enter image description here

<style>
    .column
    {
        width: 200px;
        height: 50px;
        background: yellow;
        float: left;
    }
</style>

//the repeater stretches as browser gets wider
<asp:Repeater ID="Repeater1" runat="server" >
    <ItemTemplate>
        <div class="column"> <%# Eval("FirstName") %> </div>
        <div class="column"> <%# Eval("LastName") %>  </div>
        <div class="column"><asp:LinkButton ID="Linkbutton1" runat="server" Text="Edit" CommandName="Edit" /></div>
        <div class="column"><asp:LinkButton ID="Linkbutton2" runat="server" Text="Delete" CommandName="Delete" /></div>
    </ItemTemplate>
</asp:Repeater>

1 个答案:

答案 0 :(得分:1)

使用table(html)或GridView(ASP.NET控件)显示表格数据。

或者,如果您想坚持自己的设计,请将Repeater放在div的固定宽度为800px(所有4 divs的总和)的其他<style> .table { width: 800px; } .column { width: 200px; height: 50px; background: yellow; float: left; } </style> <div class="table"> <asp:Repeater ID="Repeater1" runat="server" > <ItemTemplate> <div class="column"> <%# Eval("FirstName") %> </div> <div class="column"> <%# Eval("LastName") %> </div> <div class="column"><asp:LinkButton ID="Linkbutton1" runat="server" Text="Edit" CommandName="Edit" /></div> <div class="column"><asp:LinkButton ID="Linkbutton2" runat="server" Text="Delete" CommandName="Delete" /></div> </ItemTemplate> </asp:Repeater> </div> 中:

{{1}}