?
Solved

Format Column in Gridview

Posted on 2006-07-11
1
Medium Priority
?
443 Views
Last Modified: 2012-06-22
Morning,

im connecting to a access database and it returns the values fine in my gridview, but im having diffilculty formating the fields

the date column is returned as "11/07/2006 00:00:00" and I just want "11/07/2006"

ive tried:
<asp:BoundField DataField="HDate" HeaderText="Date" DataFormatString="{0:MM/dd/yyyy}"/>
<asp:BoundField DataField="HDate" HeaderText="Date" DataFormatString="{0:d}" />

but still get "11/07/2006 00:00:00"

any ideas?

Also the other column returns a number "7.00200000000001" and I just want to round it up or down "7"

not sure about this one but tried
<asp:BoundField DataField="Free" HeaderText="Free" DataFormatString="{0:g}" />

but still get  "7.00200000000001"

thanks
0
Comment
Question by:ziwez0
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
SystemExpert earned 2000 total points
ID: 17080133
Hi

use this in your databound event

Convert.ToDateTime(drAdded[rowindex]["EFFECTIVEDATEFROM"]).ToString("MM/dd/yyyy")

protected void itemDataBound(object sender, DataGridItemEventArgs e)
  {      
            if  (e.Item.ItemType!=ListItemType.Header && e.Item.ItemType!=ListItemType.Footer)    

             {
                    &nbs p; total += float.Parse(e.Item.Cells[1].Text);
                      e.Item.ForeColor = System.Drawing.Color.Blue;
                 }
                 else if (e.Item.ItemType == ListItemType.Footer)
                {
                     e.Item.Cells[0].Text = "Total";
                     e.Item.Cells[1].Text = total.ToString();
                }
          }

hope you get my point what i try to say

Thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question