473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2131
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tim Graichen | last post by:
Hello, I am making use of the Active X calendar control (mscal.Calendar.7) in several places in my main form, with the following code Below is an example of the code I'm using for the...
3
by: JingleBEV | last post by:
Hi all, I have a masked text control that would return a date in string format via the mask property like: "9/23/2004" and i have a calendar control that would pop up when I click a command...
6
by: Dave Hopper | last post by:
Hi I am using the following SQL to retrieve a value in a list box using a unique ID held in the list box call cntID. The list box is used on an order form to list appointments that have been...
0
by: maxrawson | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
2
by: Caesar Augustus | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
1
by: Frank Bishop | last post by:
I have a user control that will open and close the calendar control when the user clicks on an anchor tag. Instead of having the user remember to close the calendar after they make a day selection,...
3
by: Peter | last post by:
Is there anyway to make the System.Web.UI.WebControls.Calendar to display only Month Name and Year, like: January, 2006 February, 2006 ..... .... .... ....
2
by: jodyblau | last post by:
I am trying use a Calendar Control 10.0 in one of my forms. (I am using access 2002) What I want to do is have the user click a button which makes the calendar visible. Then when the user...
4
by: rushikesh.joshi | last post by:
Hi All, I want to create custom control by using Web.UI.WebControls.Calendar, in which I want to set few days with different color. I had created two property to set the color and storing in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.