I have a asp.net (WebForms) application which has a details view (insert Mode) to add new data.
2 of its fields are datetime
type. I have defined the SQL Server database columns as datetime
.
Now whenever I'm trying to add date and time it says that it doesn't match the format!
I have seen people having the same problem but unfortunately their solutions didn't work for me. How can i make sure the format matches? Is it possible to display the current datetime as a sample so the user follow it?
Thanks in advance!
DetailsView Code:
<Fields>
<asp:BoundField DataField="projectName" HeaderText="projectName" SortExpression="projectName" />
<asp:BoundField DataField="projectType" HeaderText="projectType" SortExpression="projectType" />
<asp:BoundField DataField="subjectName" HeaderText="subjectName" SortExpression="subjectName" />
<asp:BoundField DataField="studentID" HeaderText="studentID" SortExpression="studentID" />
<asp:BoundField DataField="supervisorID" HeaderText="supervisorID" SortExpression="supervisorID" />
<asp:BoundField DataField="startDate" HeaderText="startDate" SortExpression="startDate" />
<asp:BoundField DataField="dueDate" HeaderText="dueDate" SortExpression="dueDate" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
Check Your PC Date format and enter date of same format in due date if you enters the date time dynamically then use like this
DateTime.Now.ToString(yyyy-MM-dd)
here yyyy-MM-dd is my date format enter yours format in this and this is for current date you can use it for the date you desired