convert Textbox to Dollars and Cents

jeffreyjseaman used Ask the Experts™
I have a GridView that contains an editable textbox. This textbox is databinding against the database and displaying the dollars and cents vale. The field in the SQL Server DB is small money.

It's currently displaying: 4.0000 but I want it to only have 2 decimals. 4.00 or 24.00 etc;

Please tell me how to do this.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


I got it to work by doing the following;
Dollars.Text = Double.Parse(Dollars.Text).ToString("N2")

But my issue is I have BoundFields that I need to do the same with. Here is an example of my BoundField. How do I do what I did above for a textbox to a boundfield?

<asp:BoundField DataField="DollarsCents" HeaderText="DollarsCents"/><asp:BoundField />
Senior Software Developer
Top Expert 2009
Reza RadConsultant, Trainer
use this tag inside  your boundfield:

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial