我有这个转发器我得到这个...........我想要4列而不是5或6,具体取决于浏览器大小........谢谢..
<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>
答案 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}}