Separate semicolon number for thousands asp.net
How do you make seperated numbers with commas for every thousand in asp.net gridview (with c # in the back)
I tried the following lines (individually) in the backend (nothing works, they just turned off the decimals)
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");
the string is a reference to a table in the database (I iterate over each returned object and loop through the rows)
I put this when I bind to the gridview. So basically I change these attributes to a comma right before binding, but it doesn't.
The lines I've tried will change this
1092.00
to that
1092
but i am trying to achieve this
1,092
* EDIT *
This is in the template field (because I need 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>
+3
source to share
2 answers