[英]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'. 我想从数据库中检索日期并将其设置为HTML5输入类型“日期”。 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. 我有两个HTML5日期字段,其ID为“ CourseStartDate”和“ CourseEndDate”,并使用以下代码,但无法获取HTML5日期中的值。
CourseStartDate.Value = coursedr["Start_Date"].ToString();
CourseEndDate.Value = coursedr["End_Date"].ToString();
You should try to convert the date time into specific format accepted by HTML5 control. 您应该尝试将日期时间转换为HTML5控件接受的特定格式。
CourseStartDate.Text = DateTime.UtcNow.ToString("yyyy-MM-dd");
Hope this will help. 希望这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.