Aaron Anodide
Aaron Anodide

Reputation: 17196

Using inline expression with SessionParameter fails

This works as fine in my ASP.NET page's SqlDataSource:

<asp:SessionParameter Name="FromTimestamp" SessionField="fromtime" DefaultValue="2/22/2012" />

Why does this produces error: Conversion failed when converting date and/or time from character string.

<asp:SessionParameter Name="FromTimestamp" SessionField="fromtime" DefaultValue='<%=DateTime.Now.ToShortDateString()%>' />

Upvotes: 1

Views: 273

Answers (1)

Dave
Dave

Reputation: 4412

DateTime.Now.ToString("M/d/yyyy")

Will get you the format you already know works.

Upvotes: 2

Related Questions