Ravindar, Biztalk Developer and Administrator

Just another BizTalk blog

Format Date, numeric values in the DataGrid

There are two ways to modify the format of the data in a datagrid. One is through the design view. Right click on the data grid and select Property Builder and select the Column view, under the selected column select the desired column for which you wan to set the format. Then Under the Bound Column Properties section set the data formatting expression value to the desired format the selected column.

The other way to do is to edit the HTML of the page and add the dataformatstring attribute in the BoundColumn tag of the desired column.

The Format expressions are as follows: –

1. This will display a text Price: followed by the numeric text in currency format

Data Format String value : Price: {0:C}

NOTE : THE ABOVE MENTIONED FORMAT IS USING A ZERO IT IS NOT THE ALPHABET O

Applied to numeric and decimal data types.

The currency format is according to the culture info set in the web config file.

2. Integers are displayed in a zero-padded field four characters wide.

Data Format String value : {0:D4}

Applied to integer datatype only.

3. To show two decimal places followed by “%”

Data Format String value : {0:N2}%

Applied to integer datatype only.

4. To round the numbers to one decimal place and are zero padded for numbers less than three digits.

Data Format String value : {0:000.0}

Applied to numeric and decimal datatype only.

5. Long Date format

Data Format String value : {0:D}

Applied to date and datetime datatype only.

( the above formatting is as set in the web config)

6. Short Date format

Data Format String value : {0:d}

Applied to date and datetime datatype only.

( the above formatting is as set in the web config)

6. Numeric Date format

Data Format String value : {0:yy-MM-dd}

Applied to date and datetime datatype only.

Advertisements

January 27, 2010 - Posted by | Asp.Net

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: