请告诉我如何在<asp:DataList /
&gt;中显示以下HTML?或<asp:GridView />
而不影响页面中的其他内容。
<div class="products">
<div class="cl"> </div>
<ul>\\Products
<li> <a href="#"><img src="css/images/Newly_Launched/HTC_One_801e_GSM_Mobile_Phone.jpg" alt="" /></a>
<div class="product-info">
<h3>Newly Arraival</h3>
<div class="product-desc">
<p>HTC One 801e GSM Mobile phone</p> <strong class="price">Rs. 42,990</strong>
</div>
</div>
</li>
<li> <a href="#"><img src="css/images/Newly_Launched/MIcrosoft_Xbox_360_Slim_4GB.jpg" alt="" /></a>
<div class="product-info">
<h3>Newly Arraival</h3>
<div class="product-desc">
<h4> </h4>
<p>Microsoft xbox 360 slim 4gb </p> <strong class="price">Rs. 26,990</strong>
</div>
</div>
</li>
</ul>
<div class="cl"> </div>
</div>
答案 0 :(得分:0)
请使用Repeater而不是
<div class="products">
<div class="cl"> </div>
<ul>\\Products
<asp:Repeater id="rp" runat="server">
<div class="product-desc">
<p><%#Eval("Description") %></p> <strong class="price">Rs. <%#Eval("Price") %></strong>
</div>
</div>
</li>
答案 1 :(得分:0)
使用Repeater
<div class="products">
<div class="cl"> </div>
<ul>
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<li>
</HeaderTemplate>
<ItemTemplate>
<a href="#">
<img src='<%#Eval("Image") %>' alt="" /></a>
<div class="product-info">
<h3><%#Eval("Title") %></h3>
<div class="product-desc">
<p><%#Eval("Name") %></p>
<strong class="price"><%#Eval("Price") %></strong>
</div>
</div>
</ItemTemplate>
<FooterTemplate>
</li>
</FooterTemplate>
</asp:Repeater>
</ul>
<div class="cl"> </div>
</div>
答案 2 :(得分:0)
如果您想使用<asp:GridView />
,那么您需要设计ItemTemplate,如下所示。这是供您参考,设置数据源并相应地更改Eval("____")
属性名称。
<div class="products">
<div class="cl"> </div>
<asp:GridView ID="grdProducts" runat="server" Width="100%" CellPadding="0" CellSpacing="0">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href="#"><img src='<%# Eval("ImageURL") %>' alt="" /></a>
<div class="product-info">
<h3>New Arrival</h3>
<div class="product-desc">
<p><%# Eval("Description") %></p> <strong class="price"><%# Eval("Price") %></strong>
</div>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<div class="cl"> </div>
</div>