Home Ask Login Register

Developers Planet

Your answer is one click away!

Y2J February 2016

How to retrieve Date value from Database using C#.net and set in HTML5 input Type 'date'?

I want to retrieve date from database and set into HTML5 input type 'date'. I have two HTML5 date fields with IDs 'CourseStartDate' and 'CourseEndDate', and using the following code but couldn't getting the value in HTML5 date.

   CourseStartDate.Value  = coursedr["Start_Date"].ToString();
   CourseEndDate.Value    = coursedr["End_Date"].ToString();


Sachin Trivedi February 2016

You should try to convert the date time into specific format accepted by HTML5 control.

CourseStartDate.Text = DateTime.UtcNow.ToString("yyyy-MM-dd");

Hope this will help.

Post Status

Asked in February 2016
Viewed 2,493 times
Voted 11
Answered 1 times


Leave an answer

Quote of the day: live life