Asp.net 中继器控制中的水平定向

Asp.net 中继器控制中的水平定向,asp.net,repeater,Asp.net,Repeater,我有一个中继器控制用来显示上传的图像 如何水平显示中继器中的图像?我如何才能在这张图片的底部给出标题?假设您有这样的代码: <asp:repeater ...> </asp:repeater> 只需在“中插入一些html代码,使其具有您想要的外观和感觉。水平或垂直显示没有什么特别之处,它只取决于您在项目模板中使用的html标记。如果您不特别需要转发器来执行此操作,您可以使用数据列表,并设置RepeatDirection=“horizontal”取决于您使用的显示内

我有一个中继器控制用来显示上传的图像


如何水平显示中继器中的图像?我如何才能在这张图片的底部给出标题?

假设您有这样的代码:

<asp:repeater ...>

</asp:repeater>


只需在
中插入一些html代码,使其具有您想要的外观和感觉。水平或垂直显示没有什么特别之处,它只取决于您在项目模板中使用的html标记。

如果您不特别需要转发器来执行此操作,您可以使用数据列表,并设置
RepeatDirection=“horizontal”
取决于您使用的显示内容,例如,如果您的图片位于div中,则put
float:left,或者使用数据列表。

您可以像这样构建ItemTemplate:

<ItemTemplate>
    <div class="floating">
        <img src='<%# /* Code to Eval your image src from datasource */ %>' alt='' />
        <span><%# /* Code to Eval your image caption from datasource */ %></span>
    </div>
</ItemTemplate>
我通常在一系列浮动元素之后放一个div来清除,以重置box模型的状态

<div style="clear:both;"></div>

如何在每行后面显示水平线

<asp:DataList ID="dlstmovie" runat="server" onitemcommand="dlstmovie_ItemCommand" RepeatColumns="5" ItemStyle-CssClass="item1" RepeatDirection="Horizontal"  onitemdatabound="dlstmovie_ItemDataBound" >
    <ItemTemplate>
        <asp:LinkButton ID="lnkimg" runat="server" CommandName="m1" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"cinemaid")%>'>
            <img src='<%=cinemaposter %><%#Eval("picturenm")%>' class="img" />
        </asp:LinkButton>
        <br />

        <asp:LinkButton ID="lnkmovie" runat="server" CommandName="m1" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"cinemaid")%>' Text='<%#(Eval("cinemanm").ToString().Length>10)?(Eval("cinemanm").ToString().Substring(0,10))+"":Eval("cinemanm").ToString()%>' CssClass="blacktext"></asp:LinkButton>
        <asp:LinkButton ID="LinkButton1" runat="server" CommandName="m1" CommandArgument ='<%#DataBinder.Eval(Container.DataItem,"cinemaid")%>' Font-Underline="false" CssClass="blacktext">...</asp:LinkButton>

    </ItemTemplate>
    <FooterTemplate>
        <asp:Label ID="lblEmptyData" Text="No Data To Display" runat="server" Visible="false" CssClass="blacktext">
        </asp:Label>
    </FooterTemplate>
</asp:DataList>

'class=“img”/

...
就像@numenor所说的,这只是你使用什么html的问题。下面是一个如何使用html表完成所需内容的示例

<table width="<%= this.TotalWidth %>">
    <tr>
        <asp:Repeater runat="server" ID="rptABC" OnItemDataBound="rptABC_ItemDataBound">
            <ItemTemplate>
                <td class="itemWidth">
                     Your item goes here and will be 
                     displayed horizontally as a column.
                </td>
            </ItemTemplate>
        </asp:Repeater>
    </tr>
</table>
<table width="<%= this.TotalWidth %>">
    <tr>
        <asp:Repeater runat="server" ID="rptABC" OnItemDataBound="rptABC_ItemDataBound">
            <ItemTemplate>
                <td class="itemWidth">
                     Your item goes here and will be 
                     displayed horizontally as a column.
                </td>
            </ItemTemplate>
        </asp:Repeater>
    </tr>
</table>
protected string TotalWidth
{
    get
    {
        //In this example this.Madibu.Materiales is the datasource for the Repeater,
        //so this.Madibu.Materiales.Count is the column count for your table.
        //75 must be equal to the width defined in CSS class 'itemWidth'
        return (this.Madibu.Materiales.Count * 75).ToString() + "px";
    }
}