• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2405
  • Last Modified:

how to format currency and Date in Datagrid and ListView control

I am doing a project in Vb.net . 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.
  • 2
1 Solution
Bob LearnedCommented:
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.

Bob LearnedCommented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now