B
bill yeager
I would like to place the currently selected date
(retrieved from the database) on a calendar control which
is embedded inside a datagrid. However, I can't find the
ID of the control to do so. During the "Edit" command of
the grid, I have the following code:
<code>
If e.CommandName = "Edit" Then
Dim myDatagridItem As DataGridItem
Dim lblStartDate As Label
Dim lblEndDate As Label
For Each myDatagridItem In
dgPositions.Items
lblStartDate =
myDatagridItem.Controls.Item(4).FindControl
("lblStartDate")
lblEndDate =
myDatagridItem.Controls.Item(5).FindControl("lblEndDate")
Next
End If
</code>
This code successfully retrieves the date. In edit mode,
I have the textbox turning into a calendar control (When
not in edit mode, it's simply a textbox dispolaying the
date). When I go into edit mode, the selected date goes
away. I want to take the date from the code above, and
use it to set the calendar.selecteddate property so the
user can see the present date selected in the calendar
control.
The following code only works during the OnupdateCommand
and not during the "Edit" command of the grid:
<code>
Dim calStartDate As WebControls.Calendar = DirectCast
(e.Item.FindControl("calStartDate"), WebControls.Calendar)
Dim calEndDate As WebControls.Calendar =
DirectCast(e.Item.FindControl("calEndDate"),
WebControls.Calendar)
</code>
How can I properly set the "original" date to the
calendar control during the edit process?
Below, is what is in the HTML portion of my aspx page:
<code>
<asp:TemplateColumn HeaderText="StartDate">
<ItemTemplate>
<asp:Label id=lblStartDate runat="server" Text='<%
# DataBinder.Eval
(Container, "DataItem.StartDate", "{0:d}") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Calendar id="calStartDate" Runat="server">
<TodayDayStyle Font-Size="XX-
Small"></TodayDayStyle>
<SelectorStyle Font-Size="XX-
Small"></SelectorStyle>
<DayStyle Font-Size="XX-Small"></DayStyle>
<NextPrevStyle Font-Size="XX-
Small"></NextPrevStyle>
<DayHeaderStyle Font-Size="XX-
Small"></DayHeaderStyle>
<SelectedDayStyle Font-Size="XX-
Small"></SelectedDayStyle>
<TitleStyle Font-Size="XX-Small"></TitleStyle>
<WeekendDayStyle Font-Size="XX-
Small"></WeekendDayStyle>
<OtherMonthDayStyle Font-Size="XX-
Small"></OtherMonthDayStyle>
</asp:Calendar>
</EditItemTemplate>
</asp:TemplateColumn>
</code>
(retrieved from the database) on a calendar control which
is embedded inside a datagrid. However, I can't find the
ID of the control to do so. During the "Edit" command of
the grid, I have the following code:
<code>
If e.CommandName = "Edit" Then
Dim myDatagridItem As DataGridItem
Dim lblStartDate As Label
Dim lblEndDate As Label
For Each myDatagridItem In
dgPositions.Items
lblStartDate =
myDatagridItem.Controls.Item(4).FindControl
("lblStartDate")
lblEndDate =
myDatagridItem.Controls.Item(5).FindControl("lblEndDate")
Next
End If
</code>
This code successfully retrieves the date. In edit mode,
I have the textbox turning into a calendar control (When
not in edit mode, it's simply a textbox dispolaying the
date). When I go into edit mode, the selected date goes
away. I want to take the date from the code above, and
use it to set the calendar.selecteddate property so the
user can see the present date selected in the calendar
control.
The following code only works during the OnupdateCommand
and not during the "Edit" command of the grid:
<code>
Dim calStartDate As WebControls.Calendar = DirectCast
(e.Item.FindControl("calStartDate"), WebControls.Calendar)
Dim calEndDate As WebControls.Calendar =
DirectCast(e.Item.FindControl("calEndDate"),
WebControls.Calendar)
</code>
How can I properly set the "original" date to the
calendar control during the edit process?
Below, is what is in the HTML portion of my aspx page:
<code>
<asp:TemplateColumn HeaderText="StartDate">
<ItemTemplate>
<asp:Label id=lblStartDate runat="server" Text='<%
# DataBinder.Eval
(Container, "DataItem.StartDate", "{0:d}") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Calendar id="calStartDate" Runat="server">
<TodayDayStyle Font-Size="XX-
Small"></TodayDayStyle>
<SelectorStyle Font-Size="XX-
Small"></SelectorStyle>
<DayStyle Font-Size="XX-Small"></DayStyle>
<NextPrevStyle Font-Size="XX-
Small"></NextPrevStyle>
<DayHeaderStyle Font-Size="XX-
Small"></DayHeaderStyle>
<SelectedDayStyle Font-Size="XX-
Small"></SelectedDayStyle>
<TitleStyle Font-Size="XX-Small"></TitleStyle>
<WeekendDayStyle Font-Size="XX-
Small"></WeekendDayStyle>
<OtherMonthDayStyle Font-Size="XX-
Small"></OtherMonthDayStyle>
</asp:Calendar>
</EditItemTemplate>
</asp:TemplateColumn>
</code>