MSDN > フォーラム ホーム > Visual Basic General > Displaying Money on the gridview Problem
質問する質問する
 

回答済みDisplaying Money on the gridview Problem

  • 2006年7月14日 14:10Zorthgo ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     

    Hi guys,

          Maybe someone here could help me, I'm trying to take a value from the my database in the SQL server and display it in a Gridview displayed with a currency format, I've tried inserting in the DataFormatString field  {0:c}, and it still doesn't work. I have a value of 2000 on my database but on the gridview it is displayed like this 2000.0000 instead of $2,000.00. The datatype of this culumn is defined as money.

      Thanks

回答

  • 2007年4月5日 3:20Zorthgo ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み

    Hi bubbles,

    Yes it was quite simple actually. You have to set your HTMLEncode on your gridview to false. At least it worked for me. like the example below:

     

    <asp:boundfield datafield="CustomerName" headertext="Customer Name" htmlencode="false"/>

すべての返信

  • 2007年4月4日 8:03Bubbles ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Hi

    Did you ever get a solution to this problem.
    I seem to have the same problem.
    Thanks if you can help
  • 2007年4月5日 3:20Zorthgo ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み

    Hi bubbles,

    Yes it was quite simple actually. You have to set your HTMLEncode on your gridview to false. At least it worked for me. like the example below:

     

    <asp:boundfield datafield="CustomerName" headertext="Customer Name" htmlencode="false"/>

  • 2007年4月5日 10:15Bubbles ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Hi
    Thanks for your reply , but it doesn't work for me.
    Think I'll scrap the currency field and use decimals.
    Thanks again
  • 2007年4月5日 11:51Wobbs ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     

    Hi Bubbles

     

    Just thought I would check with you that you are including the HtmlEncode="False" and DataFormatString="{0:c} in your code?

     

    So for example:

    <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" HtmlEncode="False" DataFormatString="{0:c}" />

     

     

  • 2007年4月5日 12:55Bubbles ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Thanks everybody for your help the HtmlEncode="False" and DataFormatString="{0:c}

    Seems to have fixed the problem  Sorry Zorthgo I must have made a mistake when I first tried it