English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

have to get fields filled by user in the database.... for date of birth field i've given smalldatetime data type...and on .aspx file i've given dropdownlist controls for month, day and textbox for year.. How to get these three values in one column of table, dob??

2006-11-28 07:14:33 · 1 answers · asked by ally 1 in Computers & Internet Programming & Design

1 answers

Do something like this.

int MyYear = int.Parse(txtYear.Text);
int MyMonth =
int.Parse(lstMonth.SelectedItem.Value);
int MyDay =
int.Parse(lstDay.SelectedItem.Value);
DateTime MyDateTime =
new DateTime(
MyYear, MyMonth, MyDay);

Yahoo buggers up the code, but basically parse yourself an integer for each of the separate values, and then use the constructor of the DateTime object, and provide the value for the day, year, and month in the appropriate constructor parameters.

DateTime constructor docs:

http://msdn2.microsoft.com/en-us/system.datetime.datetime.aspx

2006-11-28 07:22:52 · answer #1 · answered by evolver 6 · 0 0

fedest.com, questions and answers