Conditionally set 'SelectedDate' property of Calendar based on value from sqldatasource

Apr 23 2008 10:58 AM

Arg.. Is there a way to do this?
I need to discover a way to evaluate the datetime value of the DueDate field prior to setting the SelectedDate value of the Calendar(in edit mode of a templatefield).    If the value is null, I need to not set the proprty of the calendar at all.    If the value is not null, then go ahead and set the SelectedDate property as equal to the value retrieved from the sqldatasource.
I've been scratching my head for a while on this one.   ANY ideas or suggestions would be greatly appreciated.
Here are the applicable code (simple calendar("Calendar1") not shown:
<%@ Page EnableViewState="true" Language="C#" AutoEventWireup="true" Inherits="CommunityServer.Controls.CSThemePage" MasterPageFile="tasks.Master" %>
<%@ Import Namespace="CommunityServer.Components" %>
<%@ Register TagPrefix="CSUserControl" TagName="AdTop" Src="../Themes/leanandgreen/Common/Ad-Top.ascx" %>
<%@ Register TagPrefix="CSUserControl" TagName="AdBottom" Src="../Themes/leanandgreen/Common/Ad-Bottom.ascx" %>
 <script language="cs" runat="server">
          string Username = CSContext.Current.User.Username;
          void Page_Load()
          {
              TextBox1.Text = Username;
          }
</script>

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:tasksdbConnectionString %>"
            SelectCommand="SELECT [DueDate], [Priority], [ProjTitle], [Desc], [TaskID], [Title], [Status] FROM [ToDoItems] WHERE ([Owner] = @Owner) AND ([TaskID] = @TaskID)"
            UpdateCommand="UPDATE [ToDoItems] SET [Priority] = @Priority, [ProjTitle] = @ProjTitle, [Title] = @Title, [Status] = @Status, [Desc] = @Desc, [DueDate] = @DueDate WHERE [TaskID] = @TaskID" OnSelected="Date_Select" >
            <SelectParameters>
                 <asp:QueryStringParameter Name="TaskID" QueryStringField="TaskID" Type="Int32" />
                 <asp:ControlParameter ControlID="TextBox1" Name="Owner" PropertyName="Text" Type="String" />
            </SelectParameters>


Answers (2)