Formatting columns in a GridView

Formatting columns in a GridView is relatively straightforward, once you know the appropriate format string.

Here are the steps if you are using Expression Web, Visual Studio, or Visual Web Developer:

  1. Open the Task Pane of your GridView and select Edit Columns
  2. In the Selected Fields Box, select the column you want to edit
  3. Find the HTMLEncode property and set it to false.
  4. Find the DataFormatString property and set it to the appropriate formatstring. The standard format of a format string is {0:format string}

Some examples of format strings are:

{0:c} to format as currency
{0:M-dd-yyyy} to format as a date

For more formatting strings, go to Formatting Types on MSDN.

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

Comments

No comments yet.

Leave a comment

(required)

(required)