label is showing 4 Decimal positions how to set it to two. [Resolved]

Posted by Ksuresh under C# on 1/21/2012 | Points: 10 | Views : 1511 | Status : [Member] | Replies : 3
Hi,
I am assigning value to label
labelid.text = value.ToString();// 
label is showing 3.9500 value = i am passing 3.95 value, i need label should show 3.95 only

thanks




Responses

Posted by: Sandeepkasar on: 1/22/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved


hi,
try this

double x = 1.457323;
textBox1.Text = String.Format("{0:0.00}",x); //1.46

Sandeep


Ksuresh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 1/21/2012 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Ksuresh,

show ur value variable type . . what u want . .if ur value variable like string show use substring and fix it Like . .

value.ToString().Substring(0, 4).ToString();

if type is decimal so use Round Function . .

Best Regard's
Prabhakar

Ksuresh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ksuresh on: 1/21/2012 [Member] Starter | Points: 25

Up
0
Down
lblpromotioncharge.Text = "-$" + objPromoAmount.ToString();


In Database table it is "smallmoney" and in SQL Query i used ROUND function

objPromoAmount = 3.95;

but on .aspx i want to show this value but it is appearing like 3.9500.

And Many Thnaks the above given Suggestion is working fine,once again thanks.

Regards
Suresh

Ksuresh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response