How do you do separate numbers with commas for every thousand on asp.net gridview (with c# in the back)
I have been trying the following lines (individually) in the backend(nothing works, they just cut off the decimal places)
row["Applied_Amount_Varience_Sum"] = string.Format("{0:#,###0}", Convert.ToDecimal(row["Applied_Amount_Varience_Sum"]));
row["Applied_Amount_Varience_Sum"] = Convert.ToDecimal(row["Applied_Amount_Varience_Sum"]).ToString("#,##0.00");
row["Applied_Amount_Varience_Sum"] = String.Format("{0:n}", Convert.ToDecimal(row["Applied_Amount_Varience_Sum"]));
row["Applied_Amount_Varience_Sum"] = Convert.ToDecimal(row["Applied_Amount_Varience_Sum"]).ToString("N0");
row is a reference to the table in the database (I am looping through each object returned and going through the rows)
I have putting this where I bind to the gridview. So basically I right before it binds I change those attributes to have a comma but it doesn't do that
The lines I tried will change this
1092.00
to this
1092
but I am trying to achieve this
1,092
* EDIT *
This is within a template field (because I needed it to be a link with an onclick function
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Applied Amount Variance">
<ItemTemplate>
<asp:LinkButton ID="LbPath" runat="server"
Text='<%# Eval("Applied_Amount_Varience_Sum") %>'
CommandName="BindExpand"
OnCommand="BindExpand"
CommandArgument='<%#Bind("Applied_Amount_Varience_Sum") %>'>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>