Click here to Skip to main content
15,909,324 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello i want to remove (-) sign from gridview row.

What I have tried:

Suppose in my grid view i have a calculation column where my row value is display like (-10,000) but i want to remove the minus (-) sign from the string and just display (10,000) i have tried with
DataFormatString="{0:C}"
but here i am getting $ sign please help me to just display numbers (10,000)

<asp:BoundField DataField="Calc" HeaderText="Calc" DataFormatString="{0:C}" />
Posted
Updated 25-Oct-17 21:37pm
Comments
phil.o 25-Oct-17 5:57am    
If you do that, how will you be able to discriminate between negative and positive values? The minus sign carries a meaning, which may or may not be useful, depending on your requirement, which we don't know.
AZHAR SAYYAD 25-Oct-17 6:35am    
i want only positive number
Karthik_Mahalingam 25-Oct-17 6:47am    
use  Reply  button, to post Comments/query to the user, so that the user gets notified and responds to your text.

try this, it may fit your requirement
change the -value in the data source
DataTable dt = new DataTable();
           dt.Columns.Add("Calc");
           dt.Rows.Add(-1234567890);
           dt.Rows.Add(-10000);

           dt.Columns.Add("CalcMinusRemoved");
           foreach (DataRow row in dt.Rows)
           {
               row["CalcMinusRemoved"] =  Convert.ToDouble( row["Calc"]).ToString("#,#", CultureInfo.InvariantCulture).Replace("-","");
           }


<asp:BoundField DataField="CalcMinusRemoved" HeaderText="Calc"  />
 
Share this answer
 
You could try this format string:
C#
DataFormatString="{0:#,#;#,#}"

You can find more information on custom format strings there:
Custom Numeric Format Strings[^]
 
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