locked
Incorrect price displaying in wingtip toys tutorial RRS feed

  • Question

  • User-1548075503 posted

    Hi, I am doing assignments on wingtip toys as part of my degree program, I was modifying the product page and for some reason everywhere the price is mentioned it says XDR instead of $. I am wondering what is causing this.

    I have screenshots of this HERE.

    dbo.Products looks like THIS.  

    Below is the code for ProductList.aspx if that is of any importance, I can't figure out where <b>Price: </b><%#:String.Format("{0:c}", Item.UnitPrice)%> leads to

    	<%@ Page Title="Products" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" 
             CodeBehind="ProductList.aspx.cs" Inherits="WingtipToys.ProductList" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
        <section>
            <div>
                <hgroup>
                    <h2><%: Page.Title %></h2>
                </hgroup>
    
                <asp:ListView ID="productList" runat="server" 
                    DataKeyNames="ProductID" GroupItemCount="4"
                    ItemType="WingtipToys.Models.Product" SelectMethod="GetProducts">
                    <EmptyDataTemplate>
                        <table >
                            <tr>
                                <td>No data was returned.</td>
                            </tr>
                        </table>
                    </EmptyDataTemplate>
                    <EmptyItemTemplate>
                        <td/>
                    </EmptyItemTemplate>
                    <GroupTemplate>
                        <tr id="itemPlaceholderContainer" runat="server">
                            <td id="itemPlaceholder" runat="server"></td>
                        </tr>
                    </GroupTemplate>
                    <ItemTemplate>
                        <td runat="server">
                            <table>
                                <tr>
                                    <td>
                                      <a href="<%#: GetRouteUrl("ProductByNameRoute", new {productName = Item.ProductName}) %>">
                                        <image src='/Catalog/Images/Thumbs/<%#:Item.ImagePath%>'
                                          width="100" height="75" border="1" />
                                      </a>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <a href="<%#: GetRouteUrl("ProductByNameRoute", new {productName = Item.ProductName}) %>">
                                          <%#:Item.ProductName%>
                                        </a>
                                        <br />
                                        <span>
                                            <b>Price: </b><%#:String.Format("{0:c}", Item.UnitPrice)%>
                                        </span>
                                        <br />
                                        <a href="/AddToCart.aspx?productID=<%#:Item.ProductID %>">               
                                            <span class="ProductListItem">
                                                <b>Add To Cart<b>
                                            </span>           
                                        </a>
                                    </td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                </tr>
                            </table>
                            </p>
                        </td>
                    </ItemTemplate>
                    <LayoutTemplate>
                        <table style="width:100%;">
                            <tbody>
                                <tr>
                                    <td>
                                        <table id="groupPlaceholderContainer" runat="server" style="width:100%">
                                            <tr id="groupPlaceholder"></tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td></td>
                                </tr>
                                <tr></tr>
                            </tbody>
                        </table>
                    </LayoutTemplate>
                </asp:ListView>
            </div>
        </section>
    </asp:Content>

    Wednesday, December 18, 2019 8:20 AM

All replies

  • User288213138 posted

    Hi Wick274,

    I can't figure out where <b>Price: </b><%#:String.Format("{0:c}", Item.UnitPrice)%>

    Based on your description, I tested your code, and I find it works fine in my side.

    How do you populate your data?

    <section>
            <div>
                <hgroup>
                    <h2><%: Page.Title %></h2>
                </hgroup>
    
                <asp:ListView ID="productList" runat="server" 
                    DataKeyNames="ProductID" GroupItemCount="4"
                    ItemType="Thread_Demo.Others.Products" SelectMethod="productList_GetData1">
                    <EmptyDataTemplate>
                        <table >
                            <tr>
                                <td>No data was returned.</td>
                            </tr>
                        </table>
                    </EmptyDataTemplate>
                    <EmptyItemTemplate>
                        <td/>
                    </EmptyItemTemplate>
                    <GroupTemplate>
                        <tr id="itemPlaceholderContainer" runat="server">
                            <td id="itemPlaceholder" runat="server"></td>
                        </tr>
                    </GroupTemplate>
                    <ItemTemplate>
                        <td runat="server">
                            <table>
                                <tr>
                                    <td>
                                      <a href="~">
                                        <image src='/Catalog/Images/Thumbs/<%#:Item.ImagePath%>'
                                          width="100" height="75" border="1" />
                                      </a>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <a href="~">
                                          <%#:Item.ProductName%>
                                        </a>
                                        <br />
                                        <span>
                                            <b>Price: </b><%#:String.Format("{0:c}", Item.UnitPrice)%>
                                        </span>
                                        <br />
                                        <a href="/AddToCart.aspx?productID=<%#:Item.ProductID %>">               
                                            <span class="ProductListItem">
                                                <b>Add To Cart<b>
                                            </span>           
                                        </a>
                                    </td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                </tr>
                            </table>
                            </p>
                        </td>
                    </ItemTemplate>
                    <LayoutTemplate>
                        <table style="width:100%;">
                            <tbody>
                                <tr>
                                    <td>
                                        <table id="groupPlaceholderContainer" runat="server" style="width:100%">
                                            <tr id="groupPlaceholder"></tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td></td>
                                </tr>
                                <tr></tr>
                            </tbody>
                        </table>
                    </LayoutTemplate>
                </asp:ListView>
              
            </div>
        </section>
    
    public class Products
        {
            public int ProductID { get; set; }
            public string ProductName { get; set; }
            public string  Description { get; set; }
    
            public string ImagePath { get; set; }
            public float UnitPrice { get; set; }
            public int CategoryID { get; set; }
        }
    
    public IQueryable<Products> productList_GetData1()
            {
                return new EnumerableQuery<Products>(new List<Products>
            {
                new Products{ ProductID=1, ProductName="pn1", Description="dp1", ImagePath="ip1", UnitPrice=2.99f, CategoryID=1}
            });
            }

    The result:

    Best regards,

    Sam

    Thursday, December 19, 2019 3:30 AM