如何防止 ItemTemplate 和 AlternatingItemTemplate 创建换行符
在 aspx 中,使用 ListView
、Repeater
或 Visual Studio 2010 数据工具箱下列出的任何其他标准控件: 我的数据源只是一组记录由 ID、职称、名字、姓氏、学位组成。我试图将它们打印在一行上(到达行尾时转到换行符,不一定是新记录),但是 ItemTemplate
和 AlternatingItemTemplate 似乎将每条记录打印为换行符。有没有办法摆脱自动换行符? (我尝试了
ItemSeparatorTemplate
,但这不起作用)
我认为没有必要,但我认为我只需给您代码:
<asp:ListView ID="ListView2" runat="server" DataSourceID="AccessDataSource2">
<ItemTemplate>
<a href='#<%# Eval("ID") %>' /><%# Eval("title")%> <%# Eval("first_name")%> <%# Eval("last_name")%> <%# Eval("degree")%></a>
</ItemTemplate>
<AlternatingItemTemplate>
<a href='#<%# Eval("ID") %>' /><%# Eval("title")%> <%# Eval("first_name")%> <%# Eval("last_name")%> <%# Eval("degree")%></a>
</AlternatingItemTemplate>
</asp:ListView>
In aspx, using either a ListView
, Repeater
, or any of the other standard controls that are listed under the visual studio 2010 data toolbox: My data source is simply a set of records made up of ID, title, first_name, last_name, degree. I am trying to print them on a single line (going to a newline when the end of a line is reached, not necessarily by a new record), however, the ItemTemplate
and AlternatingItemTemplate
seems to print each record as a newline. Is there a way to get rid of that automatic newline? (I tried ItemSeparatorTemplate
, but that didn't work)
I don't think that it is necessary, but I figured that I'll just give you the code:
<asp:ListView ID="ListView2" runat="server" DataSourceID="AccessDataSource2">
<ItemTemplate>
<a href='#<%# Eval("ID") %>' /><%# Eval("title")%> <%# Eval("first_name")%> <%# Eval("last_name")%> <%# Eval("degree")%></a>
</ItemTemplate>
<AlternatingItemTemplate>
<a href='#<%# Eval("ID") %>' /><%# Eval("title")%> <%# Eval("first_name")%> <%# Eval("last_name")%> <%# Eval("degree")%></a>
</AlternatingItemTemplate>
</asp:ListView>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Datalaist 并使 RepeatDirection="Horizontal"。
Use Datalaist and make RepeatDirection="Horizontal".