I want to add the current date tim开发者_StackOverflowe as default value in the following field as default value.
I tired the following
<asp:Parameter Name="AddedDate" Type="DateTime" DefaultValue="<% DateTime.Now.ToString() %>"/>
and
<asp:Parameter Name="AddedDate" Type="DateTime" DefaultValue="<% Response.Write(DateTime.Now.ToString()) %>"/>
But got error: String was not recognized as a valid DateTime.
How do i fix it? and is there any better approach?
Thanks.
You can't add a Default the way you are doing, but you can pass the DateTime.Now
as parameter in the DetailsView Inserting/Updating
event. e.g.
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{
e.Values["AddedDate"] = DateTime.Now;
}
精彩评论