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:
If e.CommandName = "Edit" Then
Dim myDatagridItem As DataGridItem
Dim lblStartDate As Label
Dim lblEndDate As Label
For Each myDatagridItem In
lblStartDate =
lblEndDate =
myDatagridItem.Controls.Item(5).FindControl("lblEn dDate")
End If

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

The following code only works during the OnupdateCommand
and not during the "Edit" command of the grid:
Dim calStartDate As WebControls.Calendar = DirectCast
(e.Item.FindControl("calStartDate"), WebControls.Calendar)
Dim calEndDate As WebControls.Calendar =

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:
<asp:TemplateColumn HeaderText="StartDate">


<asp:Label id=lblStartDate runat="server" Text='<%
# DataBinder.Eval
(Container, "DataItem.StartDate", "{0:d}") %>'>




<asp:Calendar id="calStartDate" Runat="server">

<TodayDayStyle Font-Size="XX-

<SelectorStyle Font-Size="XX-

<DayStyle Font-Size="XX-Small"></DayStyle>

<NextPrevStyle Font-Size="XX-

<DayHeaderStyle Font-Size="XX-

<SelectedDayStyle Font-Size="XX-

<TitleStyle Font-Size="XX-Small"></TitleStyle>

<WeekendDayStyle Font-Size="XX-

<OtherMonthDayStyle Font-Size="XX-



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


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.