Selceting the date in calendar control

Posted by Gokul under Regular Expressions on 12/20/2010 | Points: 10 | Views : 2754 | Status : [Member] | Replies : 3
Dear Friends
I have placed a calendar control in my application. I have a vaariable to store the selected date from the calendar control. I want to save the selected date in my DB with differerent columns like date, day and time. Can any help me in solving this...;



Regards
Gokul.N

Thanks and Regards,
GokulNath Nithy.



Responses

Posted by: Vuyiswamb on: 12/20/2010 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
You need to use the calender Properties for Different values you want.

 day and time


To get the day
Calendar1.SelectedDate.Day


Time
 Calendar1.SelectedDate.TimeOfDay


You can get all the other soft of info you want, just pass it to the function that is doing the insert to the database

Hope it Helps

Thank you for posting at Dotnetfunda
[Administrator]

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 1/8/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Calendar control in asp.net uses the below properties

Day - Allow selection of a single date.
DayWeek - Allows the selection of a single date or a complete week.
DayWeekMonth - Allow selection of single date, complete week or complete month.
None - Doesn't allow you to select any date.

Thanks
Karthik
www.f5Debug.net

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Suresh.mekkattil on: 1/9/2011 [Member] Bronze | Points: 25

Up
0
Down

Use the "SelectionChanged" event of the calendercontrol to get the date while user is selecting the date

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
DateTime selectedDate = Calendar1.SelectedDate;
string date = string.Empty;
string day = string.Empty;
string time = string.Empty;

date = selectedDate.ToShortDateString();
day = selectedDate.Day.ToString();

// If you want the week name use this statement. otherwise ignore
day = selectedDate.DayOfWeek.ToString();

time = selectedDate.ToShortTimeString();
}


-----
Suresh M

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response