我用repeater或datalist绑定了5条数据后,用代码:
<ItemTemplate>
<img src='products/<%#DataBinder.Eval(Container.DataItem,"pimg") %>' width="86" height="123" />
</ItemTemplate>
显示图片,现在想同时把文字再显示下方。用过表格或<br>都没有成功,5条记录会一条一行,最后行成一个长列,而不会5条记录显示在一行中。请高手们帮个忙,最终结果就像下面这个网站首页中的产品列表一样:
http://www.jssdrk.com/

解决方案 »

  1.   

    <table>
    <tr>
    <ItemTemplate>
    <td><img src='products/<%#DataBinder.Eval(Container.DataItem,"pimg") %>' width="86" height="123" />
    <td/>
    </ItemTemplate>
    <tr>
    </table>
      

  2.   

    <img style="display:inline;" src='products/<%#DataBinder.Eval(Container.DataItem,"pimg") %>' width="86" height="123" />
    先这样看下
      

  3.   

    <ItemTemplate>
    <img src='products/<%#DataBinder.Eval(Container.DataItem,"pimg") %>' width="86" height="123" /><br />
    </ItemTemplate>
      

  4.   

    <table>
    <tr>
    <ItemTemplate>
    <td><img src='products/<%#DataBinder.Eval(Container.DataItem,"pimg") %>' width="86" height="123" />
    <%# Eval("") %>//绑定你的文字字段
    <td/>
    </ItemTemplate>
    <tr>
    </table>
      

  5.   

    能不能把代码补充完整,我的另一个字段为:ptitle
    最终上面是pimg,下方是ptitle
    一条有5条记录,每条记录里上方是图片,下方是文字
      

  6.   


    <!--设置DataList RepeatDirection="Horizontal" 横着显示,默认竖着显示
    -->
    <asp:DataList ID="dlList" runat="server" RepeatDirection="Horizontal">
            <ItemTemplate>
                <table>
                    <tr>
                        <td><img alt="" src="img/634541922323437500.jpg" /></td>
                    </tr>
                    <tr>
                        <td class="proClass"><%# Eval("Title") %></td>
                    </tr>                
                </table>
            </ItemTemplate>
        </asp:DataList>