Click here to Skip to main content
15,894,132 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello sir,
I am doing my project in Asp.net. I know that in Visual studio data picker is present.

I dont want to use that control.So as of now i created a three combobox(ajax control).In those three combobox one is "day","month","year".Thing i made retived to all comboboxes.And One button called "Save".

In dB(SQL Server),only one column is present ie., "Date" column.If i enter a "day","month","year" and tap a "Save" button,then all the combobox get added and displayed as in single column.

Exmaple:If i select in "day" column as 20,and"month" coulmn as 3 and "year"col as 2012.
In dBase 20-03-2012 as to be displayed,.as soon as i tap a "save" button.

How to achive this sir,plz do help me..

Thanks,
Pradeep CBZ
Posted

1 solution

The DateTime structure has got a constructor overload which accepts year, month and day as arguments as explained here
DateTime Constructor (Int32, Int32, Int32)[^]
Retrieve the year, month and day from the corresponding ComboBox and create a date as shown below
C#
DateTime date = new DateTime(2012,3,20);
Console.WriteLine ("{0:dd-MM-yyyy}",date);
//output
//20-03-2012

Use the date created above to save to the database
 
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