以下是listView
和Data Pager
,
<asp:ListView runat="server" ID="PageHorizon">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server">
</asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<table width="100%">
<tr>
<td width="25%">
<img src='<%#Eval("ImagePath")%>' alt="Single Image"
width="64px" height="64px" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:ListView>
<br />
<hr />
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="PageHorizon"
PageSize="3">
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton="True"
ShowNextPageButton="True" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ShowLastPageButton="True"
ShowPreviousPageButton="True" />
</Fields>
</asp:DataPager>
通过此代码,listView
垂直显示图像,我想水平显示我的图像
如何更改listView
的方向?
答案 0 :(得分:5)
如果您只想将图像显示在一行中,则可以将它们放在单行的列中。尝试重写listview标记,如下所示(将table
,tr
标记移至LayoutTemplate
):
<asp:ListView runat="server" ID="PageHorizon">
<LayoutTemplate>
<table>
<tr>
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<td>
<img src='<%#Eval("ImagePath")%>' alt="Single Image"
width="64px" height="64px" />
</td>
</ItemTemplate>
</asp:ListView>
答案 1 :(得分:1)
我曾使用过这段代码
<asp:ListView ID="listview1" runat="server">
<ItemTemplate>
<table style="display: inline-block;">
<tr>
<td>
<asp:Image ID="Image1" runat="server" ImageUrl="<%#Bind('ImageURL') %>" CssClass="max75" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:ListView>
试一试
答案 2 :(得分:0)
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
您可以使用WrapPanel而不是StackPanel。
答案 3 :(得分:-1)