Solved

Format Column in Gridview

Posted on 2006-07-11
1
438 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
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: …

729 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