I’m simply databinding the data (containing date values) I got with a DataReader as in the following code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim id As Integer = Request.QueryString("id")
'Start connection
Dim cs As String = ConfigurationManager.ConnectionStrings("Access 2010").ConnectionString
Dim cn As New OleDbConnection(cs)
cn.Open()
'Retrieve Jobs Data
Dim cmd As New OleDbCommand
With cmd
.Connection = cn
.CommandText = "SELECT Nome, Descricao, Data, Autor FROM Jobs WHERE ID = @ID"
.CommandType = CommandType.Text
.Parameters.AddWithValue("@ID", id)
End With
Dim dbReader As OleDbDataReader = cmd.ExecuteReader()
If Not Page.IsPostBack Then
'Populate Dropdown Jobs
dtlJob.DataSource = dbReader
dtlJob.DataBind()
End If
dbReader.Close()
End Sub
And I’m getting the values like 30/12/1899 00:00:51. I checked my database and the record is correct: it appears 12/10/2011. How do I format the Date field since I just used .DataSource and .DataBind?
Find the details view on the aspx page and you need to add the
DataFromatStringtag to the bound field. IT will be something like this: