how to format currency and Date in Datagrid and ListView control

Posted on 2006-04-11
Last Modified: 2008-03-10
I am doing a project in . It is somewhat different for me as i am a vb programmer. some of the issues like formatting currency and date in Datagrid, Datalist and especially Listview control . can any one tell me how to do this format with a code sample. it will be very helpful for me.
Question by:rahaman
    LVL 96

    Accepted Solution

    Here is a DataGrid example:

    <asp:DataGrid id=DataGrid1 style="Z-INDEX: 101; LEFT: 44px; POSITION: absolute; TOP: 60px" runat="server" Width="492px" Height="192px" AutoGenerateColumns="False">
      <AlternatingItemStyle CssClass="alternatingstyle">
      <ItemStyle CssClass="itemstyle">
      <HeaderStyle CssClass="headerstyle">
        <asp:BoundColumn DataField="name" HeaderText="Name"></asp:BoundColumn>
        <asp:BoundColumn DataField="address" HeaderText="Address"></asp:BoundColumn>
        <asp:BoundColumn DataField="current_date" HeaderText="Current Date" DataFormatString="{0:dd MMM yyyy}"></asp:BoundColumn>
        <asp:BoundColumn DataField="amount_due" HeaderText="Amount Due" DataFormatString="{0:C}"></asp:BoundColumn>

    Look at the BoundColumn declarations, and the DataFormatString formats:

    Data Examples:
    (1) {0:dd MMM yyyy} = 12 Apr 2006
    (2) {0:C} = $1268.60

    You can specify these values through the 'Property Builder' for the DataGrid.

    LVL 96

    Expert Comment

    by:Bob Learned

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now