datalist显示商品列表

DataList横向显示数据

<asp:datalist id="MyList" RepeatDirection=Horizontal RepeatColumns=2 showfooter=true borderwidth=0 runat=server>
                 <HeaderTemplate>
                 <table height=100% width=288 cellpadding=0 cellspacing=0 border=0 >
                 <tr>
                 </HeaderTemplate>
                 <ItemTemplate>
                         <td>
                          <table>
                          <tr>
                          <td width=130>
                           <a href="Hotel/hotelDetail.aspx?H_ID=<%# DataBinder.Eval(Container.DataItem, "H_ID")%>" target=_blank><img height="90" width="130" border=0 src="HotelManage/pic/<%# DataBinder.Eval(Container.DataItem, "H_Pic1")%>" /></a>
                          </td>
                          </tr>
                          <tr>
                          <td>
                           <%# DataBinder.Eval(Container.DataItem, "H_Name")%>
                          </td>
                          </tr>
                          </table>
                        </td>   
              </ItemTemplate>
              <FooterTemplate>
                </tr>
                  </table>
              </FooterTemplate>
           </asp:datalist>

RepeatDirection=Horizontal 为设置为横向显示

RepeatColumns=2 每行显示2条记录

原文地址:https://www.cnblogs.com/zzxap/p/2175905.html