Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1053347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:14:17+00:00 2026-05-16T17:14:17+00:00

I have the following columns in a gridview, one is a date and the

  • 0

I have the following columns in a gridview, one is a date and the other one is a dollar amount. I applied the formatting and set the HtmlEncode property to false, however the values still come up unformatted:

<asp:BoundField DataField="Total" HeaderText="Total" ReadOnly="true" HtmlEncode="False" DataFormatString="{0:C}" />
<asp:BoundField DataField="Sale_Date" HeaderText="Sale Date" ReadOnly="true" HtmlEncode="False" DataFormatString = "{0:d}" />

This is how these values appear in the gridview:

The “Total” value comes up as: 190.0000
The Sale Date value comes up as: 9/2/2010 8:59:00 AM

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:14:18+00:00Added an answer on May 16, 2026 at 5:14 pm

    I found what the problem was. I was not able to format the boundfields from the gridview because its data type was set to a string. The data set that I am using to populate the gridview is coming from a web service, all fields in the data set are coming back as strings so that is why the DataFormatString property in the gridview was not working.

    The fix: I ended up changing the data type of these fields after I got the data set from the web service and before using it as the datasource of the grid view, once I did this, the DataFormatString property in the gridview worked as expected:

    ds = _ws.GetOrderList(brokerId, type, pageSize, pageNum, sort, searchBy, searchFor);
    ds2 = ds.Clone();
    
    ds2.Tables[0].Columns["Price"].DataType = System.Type.GetType("System.Double");
    ds2.Tables[0].Columns["Total"].DataType = System.Type.GetType("System.Double");
    ds2.Tables[0].Columns["Sale_Date"].DataType = System.Type.GetType("System.DateTime");
    
    foreach (DataRow row in ds.Tables[0].Rows)
      {
         ds2.Tables[0].ImportRow(row);
      }
    return ds2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following gridview: <asp:GridView ID=gdvReport runat=server AutoGenerateColumns=False DataSourceID=sdseport> <Columns> <asp:BoundField DataField=Phone HeaderText=Phone
I have the following gridview <asp:GridView DataSourceID=odsRooms DataKeyNames=id,objectid ID=gvRooms PageSize=10 runat=server AutoGenerateColumns=False > <Columns>
I have a gridview with couple of columns,I want to achieve the following: If
I have built a dynamic gridview using the following code grdVariants.Columns.Clear(); int i =
I have the following code in the columns section of my GridView: <Columns> <asp:boundfield
I have a asp:GridView and in there i have two columns , in one
In my GridView, I have the following columns: <Columns> <asp:BoundField DataField=report_type HeaderText=Report Type SortExpression=report_type
i have a gridview which has one of the columns as a dropdown. When
I have a very simple GridView on one of my pages with the following
I have three mysql table from same database Db1. Three tables have following columns.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.