Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you format values in a grid column

Status
Not open for further replies.

TerDavis

Technical User
Sep 18, 2002
36
US
Hi,
I have a grid with the usual stuff, Name, Phone Number and Address.

I want to display the PhoneNumber in the 123-1234 format instead of how it is being stored in the db field which is 1231234.

For a column in the grid, you cannot select a masked text box and can only select a text box. Though there is a dataviewstyle format property ....but i could not get this work correctly, ( assuming this is the correct path )..

so, how do you format a value in the grid that is a databound column such that the format value is not saved to the db and formats on load ?
 
Some options:

1. Use STUFF in the select query when selecting the Phone Number column from the database to insert a hyphen, eg. STUFF(PhoneNumber, 4, 0, '-') AS PhoneNumber.

2. Use a custom datagrid table style with a custom gridcolumnstyle (see the VS help for an example or search these forums).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top