Question Date field displaying as DateTime

richlp

Member
Joined
Oct 16, 2009
Messages
9
Programming Experience
10+
I put a DropDownList on a form. Included in the Page_Load method is the following code
If Not IsPostBack Then
.
.

Dim strConn As String = CType(Me.Master, MasterPage).connectString
Dim objConn As New MySqlConnection(strConn)
Dim objDS As New DataSet

Dim strSql As String
strSql = "SELECT DISTINCT savedate FROM kpi_mrpactionsvalue " & _
" ORDER BY savedate DESC LIMIT 10"

Dim daDates As New MySqlDataAdapter(strSql, objConn)
daDates.Fill(objDS, "dtDates")

For Each rowDate In objDS.Tables("dtDates").Rows
ddlDates.Items.Add(rowDate("savedate"))
Next

.
.
This works the way I expect (the DDL is populated with the correct 10 dates)

The next step is to try and bind the DDL to an SqlDataSource. I commented out the Page_Load code and configured the DataSource as follows
<asp: DropDownList ID="ddlDates" runat="server" Height="20px" Width="107px"
DataSourceID="mysqldatasource" DataTextField="savedate"
DataValueField="savedate">
</asp: DropDownList>

<asp:SqlDataSource ID="mysqldatasource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="< %$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="select distinct savedate from kpi_mrpactionsvalue order by savedate desc limit 10" >
</asp:SqlDataSource>

This also produces a DDL with the correct 10 dates. However, the values show up as DateTime. The Time portion is 12:00:00 AM for all the rows in the DDL. The backend is MySql and I've verified that the field in question is actually a Date rather than a DateTime

Any explanation and code corrections sincerely appreciated.............Rich
 
Back
Top