mlagrange
asked on
How to plug system date/time value in Insert parameters?
Hello - I've got a data entry page where I need to maintain input & update date-time stamps
I'm trying to set these in the parameters
<InsertParameters>
<asp:Parameter Name="MyField1" Type="Int32" />
<asp:Parameter Name="MyField2" Type="String" />
<asp:Parameter Name="MyField3" Type="String" />
...
<asp:Parameter Name="InputOn" Type="DateTime" />
<asp:Parameter Name="InputBy" Type="String" />
I tried:
<asp:Parameter Name="InputOn" Type="DateTime" DefaultValue=Now() />
but that gets:
Exception occurred: The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.
(I know one way to get around this would be to set the Default value field back in the SQL Server table, but I need to set an accompanying "UpdateOn" field if/when the record is updated, so I might as well be consistent.)
And if it's not too much trouble, can anybody point me to a more advanced reference on how to set parameter values from sources other than form fields? Like Session variables, Profile values, etc...?
Thanks
Mark
I'm trying to set these in the parameters
<InsertParameters>
<asp:Parameter Name="MyField1" Type="Int32" />
<asp:Parameter Name="MyField2" Type="String" />
<asp:Parameter Name="MyField3" Type="String" />
...
<asp:Parameter Name="InputOn" Type="DateTime" />
<asp:Parameter Name="InputBy" Type="String" />
I tried:
<asp:Parameter Name="InputOn" Type="DateTime" DefaultValue=Now() />
but that gets:
Exception occurred: The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.
(I know one way to get around this would be to set the Default value field back in the SQL Server table, but I need to set an accompanying "UpdateOn" field if/when the record is updated, so I might as well be consistent.)
And if it's not too much trouble, can anybody point me to a more advanced reference on how to set parameter values from sources other than form fields? Like Session variables, Profile values, etc...?
Thanks
Mark
ASKER
Thanks for the response, but just as typed, it got this error:
Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls. Parameter does not have a DataBinding event.
I played around with it a little:
DefaultValue='<%=Now() %>'
and
DefaultValue='<%=Now().ToS tring() %>'
both got this error:
Exception occurred: String was not recognized as a valid DateTime.
Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.
I played around with it a little:
DefaultValue='<%=Now() %>'
and
DefaultValue='<%=Now().ToS
both got this error:
Exception occurred: String was not recognized as a valid DateTime.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<asp:Parameter Name="InputOn" Type="DateTime" DefaultValue='<%# Now() %>' />