V
Vagabond Software
I'm using a DropDownList in an EditItemTemplate column. This DropDownList
will only ever have two dates in it; Now and the default DateTime value
(1/1/1900 12:00:00 AM).
Somewhere, somehow, the DropDownList is interpreting the default DateTime
value as a string value "1/1/0001 12:00:00 AM". DateTime.Parse in turn
converts that string value to #12:00:00 AM# with no date values. What am I
doing wrong here?
Here is some relevant code (I'm new to ASP.NET, so I welcome
criticism/correction on any part of this):
<asp:TemplateColumn HeaderText="Check-In Date">
<ItemStyle horizontalalign="Left" wrap="False"></ItemStyle>
<ItemTemplate>
<%#Databinder.Eval(Container.DataItem, "checkin_DT")%>
</ItemTemplate>
<EditItemTemplate>
<aspropDownList ID="ddlCheckinDT" Runat="server"
CssClass="ddl100"></aspropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
ASP web stuff...
<asp:TemplateColumn HeaderText="Check-In Date">
<ItemStyle horizontalalign="Left" wrap="False"></ItemStyle>
<ItemTemplate>
<%#Databinder.Eval(Container.DataItem, "checkin_DT")%>
</ItemTemplate>
<EditItemTemplate>
<aspropDownList ID="ddlCheckinDT" Runat="server"
CssClass="ddl100"></aspropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
EditItem Method in Codebehind...
Private Sub EditAttendeeRecord(ByVal index As Integer)
Dim defaultDate As DateTime
ddlCheckin =
DirectCast(dgAttendees.Items(index).FindControl(CTL_DDLCHECKINDT),
WebControls.DropDownList)
ddlCheckin.Items.Add(regRow.CheckIn_DT.ToString)
If regRow.CheckIn_DT.Equals(defaultDate) Then
ddlCheckin.Items.Add(DateTime.Now.ToString)
Else
ddlCheckin.Items.Add(defaultDate.ToString)
End If
End Sub
SaveItem Method in Codebehind...
Private Sub SaveAttendeeRecord(ByVal index As Integer)
regRow.CheckIn_DT =
DateTime.Parse(DirectCast(dgAttendees.Items(index).FindControl(CTL_DDLCHECKINDT),
WebControls.DropDownList).SelectedValue)
End Sub
The value of the CheckIn_DT property on my regRow data object is #12:00:00
AM# at this point in the code.
Regards,
carl
will only ever have two dates in it; Now and the default DateTime value
(1/1/1900 12:00:00 AM).
Somewhere, somehow, the DropDownList is interpreting the default DateTime
value as a string value "1/1/0001 12:00:00 AM". DateTime.Parse in turn
converts that string value to #12:00:00 AM# with no date values. What am I
doing wrong here?
Here is some relevant code (I'm new to ASP.NET, so I welcome
criticism/correction on any part of this):
<asp:TemplateColumn HeaderText="Check-In Date">
<ItemStyle horizontalalign="Left" wrap="False"></ItemStyle>
<ItemTemplate>
<%#Databinder.Eval(Container.DataItem, "checkin_DT")%>
</ItemTemplate>
<EditItemTemplate>
<aspropDownList ID="ddlCheckinDT" Runat="server"
CssClass="ddl100"></aspropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
ASP web stuff...
<asp:TemplateColumn HeaderText="Check-In Date">
<ItemStyle horizontalalign="Left" wrap="False"></ItemStyle>
<ItemTemplate>
<%#Databinder.Eval(Container.DataItem, "checkin_DT")%>
</ItemTemplate>
<EditItemTemplate>
<aspropDownList ID="ddlCheckinDT" Runat="server"
CssClass="ddl100"></aspropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
EditItem Method in Codebehind...
Private Sub EditAttendeeRecord(ByVal index As Integer)
Dim defaultDate As DateTime
ddlCheckin =
DirectCast(dgAttendees.Items(index).FindControl(CTL_DDLCHECKINDT),
WebControls.DropDownList)
ddlCheckin.Items.Add(regRow.CheckIn_DT.ToString)
If regRow.CheckIn_DT.Equals(defaultDate) Then
ddlCheckin.Items.Add(DateTime.Now.ToString)
Else
ddlCheckin.Items.Add(defaultDate.ToString)
End If
End Sub
SaveItem Method in Codebehind...
Private Sub SaveAttendeeRecord(ByVal index As Integer)
regRow.CheckIn_DT =
DateTime.Parse(DirectCast(dgAttendees.Items(index).FindControl(CTL_DDLCHECKINDT),
WebControls.DropDownList).SelectedValue)
End Sub
The value of the CheckIn_DT property on my regRow data object is #12:00:00
AM# at this point in the code.
Regards,
carl