locked
How to fomat Money value in Gridview ? RRS feed

  • Question

  • Hi , i'm asking about if i have datagrid and combobox , and both of them retrieve Money type from sql server 2008 , but when enter value such 6.9 , its entered and retrieved 6.9000 , and same for all , what is the easy way to format my decimal to be normal like real money we saw each day , thank you 

    Hesham Hemdan Saleh

    Sunday, July 22, 2012 8:46 PM

Answers

  • If you wanted to persist data in database ( eg: sql server) while keeping the format up then read link and formatting tips from here. You have to follow control level data formatting here  in order to format fount end data. Sample code can found here.

    this.dataGridView1.Columns["UnitPrice"].DefaultCellStyle.Format = "c";
    



    If this post answers your question, please click Mark As Answer. If this post is helpful please click Mark as Helpful.

    Regards,
    Nair S


    • Edited by Nair S Sunday, July 22, 2012 9:39 PM link
    • Marked as answer by HESHAM HEMDAN Tuesday, July 24, 2012 4:40 PM
    Sunday, July 22, 2012 9:39 PM

All replies

  • If you wanted to persist data in database ( eg: sql server) while keeping the format up then read link and formatting tips from here. You have to follow control level data formatting here  in order to format fount end data. Sample code can found here.

    this.dataGridView1.Columns["UnitPrice"].DefaultCellStyle.Format = "c";
    



    If this post answers your question, please click Mark As Answer. If this post is helpful please click Mark as Helpful.

    Regards,
    Nair S


    • Edited by Nair S Sunday, July 22, 2012 9:39 PM link
    • Marked as answer by HESHAM HEMDAN Tuesday, July 24, 2012 4:40 PM
    Sunday, July 22, 2012 9:39 PM
  • thanks , i will review that later 

    Hesham Hemdan Saleh

    Tuesday, July 24, 2012 4:40 PM