Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to format a datagrid column to number format with comma. this is not working in my latest application. I am using the DataFormatString property but it returns the number without comma. I even tried the format "{0:N}", but same result.
here is my code

C#
BoundColumn BoundColumn=new BoundColumn();
BoundColumn DataField=Store Quantity; 
BoundColumn.HeaderText=Quantity;
BoundColumn.ItemStyle-HorizontalAlign=Right;
BoundColumn.DataFormatString="{0:N}";


The source for the datagrid is a DataTable whcih is created dynamically.
Posted
Updated 20-Jan-12 21:35pm
v2

Make sure that in the DataTable, for the column Store Quantity, the data type is one of the numeric types (int, float etc). If it is string, then the numeric format is ignored.
 
Share this answer
 
Comments
Aravind Garre 22-Jan-12 23:37pm    
hi sriram chitturi,

Thanks For Helping....
Aravind Garre 23-Jan-12 0:02am    
hi Sriram,
i am given like this but still not coming numaric format .and i try convert to int
please find below code.
if (!(ds1.Tables[j].Rows[i]["TotalValue"] ==DBNull.Value))
{
dr["TotalValueOfOperatingSoftwares"] = ds1.Tables[j].Rows[i]["TotalValue"];

}
table.Rows.Add(dr);
GV1.DataSource = table;
GV1.DataBind();
hello Aravind
in your original code, you have mentioned "Store Quantity", what column is that related to?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900