Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have two textbox and one dropdownlist..i am entering date in 1st textbox,time in 2nd textbox and selecting am or pm from dropdownlist.i want to store this data in one column which is datetime format.plz help me?
Posted

Club all the values into single string.
C#
Page_Load()
{ 
   string strDate = textbox1.text + " " + textbox2.text + " " + dropdownlist.selectedtext;
   DateTime datetime = DateTime.Parse(strDate);
   Console.WriteLine(datetime.ToString());
}


I have tried above code, it is working as expected.

Please note: This solution will work if you ensure that correct format of date and time is entered in the textboxes else it will give you an exception.
 
Share this answer
 
v2

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