如何在转发器中以适当的表格格式放置内容?

时间:2013-08-09 08:14:45

标签: asp.net repeater

我有这样的转发器

<ul>
                    <li>
                        <div class="product">
                            <a href="#" class="info">
                                <table class="holder">
                                    <asp:Repeater ID="repContent" runat="server">
                                        <HeaderTemplate></HeaderTemplate>
                                        <ItemTemplate>

                              <%# (Container.ItemIndex + 4) % 4 == 0 ? "<tr>" : string.Empty %>

                                 <td>
                                    <img src='<%#"/productimages/main/" + Eval("PhotoName").ToString().Trim()  %>' alt="No Image" />
                                    <span class="book-name"><%#Eval("ProductName") %></span>
                                    <span class="author">by <%#Eval("CompanyName") %></span>
                                    <span class="description"><%#Eval("Description") %></span>

                                  </td>

                                <%# (Container.ItemIndex + 4) % 4 == 3 ? "</tr>" : string.Empty %>

                                            </ItemTemplate>
                                            <FooterTemplate></FooterTemplate>
                                         </asp:Repeater>
                                 </table>
                            </a>
                            <a href="#" class="buy-btn">BUY NOW <span class="price"><span class="low">$</span>22<span class="high">00</span></span></a>
                        </div>
                    </li>                   
                </ul>

它在浏览器中显示如下 the images are not in proper row and sequence 如何在转发器中以适当的行和列正确设置此内容。

请告诉我,我的代码应该是什么操作。

1 个答案:

答案 0 :(得分:0)

忽略这段HTML完全无效的事实(ul - &gt; li - &gt; div - &gt; a - &gt; ),尝试将单元格垂直对齐设置为顶部(<td valign="top">)。

一个好建议。尝试使用CSS并使用div重写它并使其有效。

<ul>
    <li>
        <div class="product">
            <a href="#" class="info">
                <table class="holder">
                    <asp:Repeater ID="repContent" runat="server">
                        <ItemTemplate>
                              <%# (Container.ItemIndex + 4) % 4 == 0 ? "<tr>" : string.Empty %>
                                  <td valign="top">
                                      <img src='<%#"/productimages/main/" + Eval("PhotoName").ToString().Trim()  %>' alt="No Image" />
                                      <span class="book-name"><%#Eval("ProductName") %></span>
                                      <span class="author">by <%#Eval("CompanyName") %></span>
                                      <span class="description"><%#Eval("Description") %></span>
                                  </td>
                              <%# (Container.ItemIndex + 4) % 4 == 3 ? "</tr>" : string.Empty %>
                          </ItemTemplate>                      
                      </asp:Repeater>
                  </table>
              </a>
              <a href="#" class="buy-btn">BUY NOW <span class="price"><span class="low">$</span>22<span class="high">00</span></span></a>
        </div>
    </li>
</ul>
相关问题