I have several parameters for the select statement in an SQL datasource. Two are date values - an optional start date and end date. Here's the definition:
<asp:ControlParameter ControlID="txtDateFrom" Name="DateFrom"
PropertyName="Text" DefaultValue="1/01/1900" Type="DateTime" />
<asp:ControlParameter ControlID="txtDateTo" Name="DateTo"
PropertyName="Text" Type="DateTime" />
I can set a DefaultValue for the DateFrom simply. But if the DateTo value hasn't been entered, I want this to default to today's date. Now, I do this in the "Selecting" event handler for the sqlDataSource:
If Me.txtDateTo.Text = String.Empty Then
e.Command.Parameters.Item("@DateTo").Value = Date.Today
End If
Now my question: is there a smarter way do to this - like having an executable expression in the DefaultValue definition itself?