Results 1 to 4 of 4

Thread: Formating Values From OleDbDataReader

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213

    Formating Values From OleDbDataReader

    I am retrieving Values from Access DB which I need to Format. I am using the following:

    myDataReader = OleDbComm.ExecuteReader()

    I want to Display the Formatted Values in a table in a DataList:

    <td><%# Container.DataItem("Price") %></td>

    The Format I want is as follows:
    Dim MyDouble As Double = 123456789
    Response.Write(MyDouble.ToString("C"))

    How can I apply this to myDataReader so that I can display the formatted value for Price ?

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I am doing this by memory, and it may be wrong, but is in the right direction.
    Code:
    <td><%# DataBinder.Eval(Container.DataItem, "Price", {0:C}) %></td>

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    I have tried this but get a 'Expression expected' error ! Any Ideas ?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213
    I have also used this method:

    <td><%# FormatValue(DataBinder.Eval(Container.DataItem, "Price")) %></td>

    Public Function FormatValue(curr As Double) As Double

    Response.Write(curr.ToString("C"))
    Return curr.ToString("C")

    End Function

    The Function Returns the Price formatted correctly as currency from Response.Write (e.g £250,000) but the value in the table is NOT formatted (i get back 250000). Why does this not work ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width