使用Datalist显示包含以下HTML代码的产品

时间:2014-01-22 10:00:52

标签: html asp.net css

请告诉我如何在<asp:DataList /&gt;中显示以下HTML?或<asp:GridView />而不影响页面中的其他内容。

<div class="products">
    <div class="cl">&nbsp;</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>&nbsp;</h4>

                    <p>Microsoft xbox 360 slim 4gb&nbsp;&nbsp;&nbsp;</p> <strong class="price">Rs. 26,990</strong> 
                </div>
            </div>
        </li>
    </ul>
    <div class="cl">&nbsp;</div>
</div>

3 个答案:

答案 0 :(得分:0)

请使用Repeater而不是

<div class="products">
    <div class="cl">&nbsp;</div>
    <ul>\\Products
       <asp:Repeater id="rp" runat="server">

 

  • “alt =”“/&gt;                                       &lt;%#Eval(“Title”)%&gt; / h3&gt;

                    <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">&nbsp;</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">&nbsp;</div>
    </div>
    

    答案 2 :(得分:0)

    如果您想使用<asp:GridView />,那么您需要设计ItemTemplate,如下所示。这是供您参考,设置数据源并相应地更改Eval("____")属性名称。

    <div class="products">
        <div class="cl">&nbsp;</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">&nbsp;</div>
    </div>