问题
I'm using a datalist control. How I can add a row separator in the datalist? I have more than one item in a row and I'm using .Net 2.0.
Separator template work for each item not for each row.
I want to display it like this.
row1-> item1 item2
---separator
row2-> item3 item4
---separator
row3-> item5 item6
回答1:
Try this:
<asp:DataList>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
</asp:DataList>
Update
If you want a simple border this way may help. the only problem is that latest row has a separator too.
<asp:DataList ID="DL1" runat="server" Width="200px" RepeatDirection="Horizontal" RepeatColumns="2" CssClass="DL1" CellPadding="0" CellSpacing="0">
<ItemTemplate>
.
.
.
</ItemTemplate>
</asp:DataList>
.DL1 td
{
border-bottom: solid 1px silver;
border-collapse: collapse;
}
回答2:
Use DataList.SeparatorTemplate Property
e.g.
<SeparatorTemplate>
<asp:Image id="SeparatorImage"
ImageUrl="SeparatorImage.jpg"
runat="server"/>
</SeparatorTemplate>
And look into this DataList.SeparatorTemplate Property
回答3:
Formatting the DataList and Repeater Based Upon Data is explained with examples here,have a look.
来源:https://stackoverflow.com/questions/1774590/row-separator-in-datalist