470,641 Members | 1,575 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,641 developers. It's quick & easy.

retrieving the original value from a calendar control

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("lblEn dDate")
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>
Nov 18 '05 #1
1 2007
check out the ItemDataBound event and also e.Item.ItemType Property. Move the code to reference the Calendar Control here

Regards

Trevor Benedict R
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Tim Graichen | last post: by
6 posts views Thread by Dave Hopper | last post: by
reply views Thread by maxrawson | last post: by
2 posts views Thread by Caesar Augustus | last post: by
1 post views Thread by Frank Bishop | last post: by
3 posts views Thread by Peter | last post: by
4 posts views Thread by rushikesh.joshi | last post: by
1 post views Thread by Korara | last post: by
???
1 post views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.