Click here to Skip to main content
14,919,896 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am new in C#.I am creating a website in which I have a textbox for joining date.I am showing date by default in textbox using DateTime.Today.ToString("yyyy/MM/dd");
I have also used a datepicker. When I use datepicker to change the date in textbox , It always insert the today's date in database.I dont know how to insert the date selected by datepicker. Plz help me.
Rob Philpott 11-Jun-13 5:54am
Need more info. Do you know how to insert other things into the database and are just having trouble with dates?
Sruthi Jain 11-Jun-13 6:21am
Is your textbox updated with the latest date selected from the datepicker?

1 solution

try using string to store date selected by datetime picker

string str= dateTimePicker1.Text;

if its web application see whether you have checked for following condition

if (!IsPostBack)

and if not put your database inserting code in that postback block

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900