format decimal value in gridview

后端 未结 4 775
刺人心
刺人心 2021-01-03 07:09

I have a bound field in my Gridview which is getting its value from a database table.

I have got the data but don\'t know how to format it inside the gridview.

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-03 07:30

    A couple of ways in how you can do that

    Option 1

    
    

    Option 2

    
    

    Option 3
    Create a method in the code behind page that returns the formatted number.

     protected string GetFormatedNumber(object number)   
     {  
       if ( number != null )  
           {  
              return number.ToString("N");  
           }  
           return "0";   
     }  
    

    And call the method in your aspx page as below:

    
    

提交回复
热议问题