开发者

ListView Coding

How do i code the "View Details" portion of my ListView to hyperlink it to the product details page? My product catalog is displayed as follows:

ListView Coding

ListView codes

<asp:ListView runat="server" ID="listView" GroupItemCount="3" 
        DataSourceID="AccessDataSource1">
    <LayoutTemplate>
        <div style="height: 966px;">
        <div style="width: 771px;">
            <asp:PlaceHolder runat="server" ID="groupPlaceHolder" />
        <asp:DataPager runat="server" ID="dpMyDatePager" PageSize="9"
 Pag开发者_开发问答edControlID="listView">
<Fields>
    <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True"
     ShowFirstPageButton="True" />
     <asp:NumericPagerField />
</Fields>
</asp:DataPager>
        </div>
    </LayoutTemplate>
    <GroupTemplate>
        <div style="clear: both;">
            <asp:PlaceHolder runat="server" ID="itemPlaceHolder" />
        </div>
    </GroupTemplate>
    <ItemTemplate>
<div class="productItem">
    <div>
        <img src='<%# Eval("ProductUrl") %>' >
    </div>
    <div class="catalog-price">
    <br />    
            <%# Eval("ProductBrand") %>
            <%# Eval("ProductModel") %></div>

    <div class="catalog-price2">
        <b>
        Our Price: S$<%# Eval("NormalPrice") %></div>
        </b><br />
    <div class="cell1">
        Add to cart</div>
    <div class="cell2">
        View details</div>
</div>
</ItemTemplate>


You have to pass the id of Selected Product to view the details of Selected Product.

Your ViewDetails button code should be like...

<asp:HyperLink ID="HypViewDetails" ImageUrl="~/Images/viewDetails.png" 
     NavigateUrl='<%#Eval("ProductId", "ProductDetails.aspx?cid={0}")%>'
     runat="server"></asp:HyperLink>


Put the view details div in a hyperlink, coded with the model id?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜