Click here to Skip to main content
14,486,704 members
Rate this:
Please Sign up or sign in to vote.
See more:
how to add percent sign in textbox after entering value .

.. ex 15%

What I have tried:

i tried by using value.tostring("p")

its stored in float datatype
Updated 19-Mar-20 6:26am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

will actually display the value as a percentage:
value   display
0.15    15%
15      1500%
If your goal is to transform 15 to 15%, then you first have to divide the value by 100:
theTextBox.Text = (value / 100).ToString("P")
kongalshiva549 19-Mar-20 12:58pm
while saving does not that percentage also save?

Iam using ef
.Per = c.PComplete,
phil.o 19-Mar-20 13:33pm
Sorry, I don't undersand your concern. Whatever the value, it will be saved. I you want to save a 15% value, then the float value you have to save is 0.15. Do not confound the value (0.15) with its string representation (15%).
kongalshiva549 19-Mar-20 14:40pm
sorry for that.. what ever the value which is stored in database while displaying just we need to add percent sign and show in textbox.
phil.o 19-Mar-20 15:39pm
Again: just save 0.15 as value in the database, and display it as percentage if you need.

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100