Setting SelectedDate in <asp:calendar

From: TenDot (TenDot_at_discussions.microsoft.com)
Date: 09/30/04

  • Next message: Ray Costanzo [MVP]: "Re: Setting SelectedDate in <asp:calendar"
    Date: Thu, 30 Sep 2004 10:53:06 -0700
    
    

    I'm trying to set the SelectedDate on an <asp:calendar tag to show the
    existing value of a date in a field retrieved from a database and put into
    edit mode in a datagrid.

    I've already got a TextBox tag in this datagrid cell that gets assigned (and
    works fine):
    <asp:TextBox id=INJECTIONDATE runat="server" Width="94px" Text='<%#
    DataBinder.Eval(Container, "DataItem.INJECTIONDATE") %>'/>

    It would seem like a no-brainer to do the following in the calendar tag that
    wants to show the date preselected in the calendar component:

    <asp:Calendar id="calINJECTIONDATE" runat="server" SelectedDate='<%#
    DataBinder.Eval(Container, "DataItem.INJECTIONDATE" ) %>'>

    But, as always seems the case with no-brainer solutions in .asp (sorry), no
    dice.

    I've done some other hoop jumping like calling a function to cast the result
    as a DateTime:
    GetDateValue(DataBinder.Eval(Container, "DataItem.INJECTIONDATE" ))

    etc. etc.

    I've done the usual searching through the literature which all assumes that
    you want today's date pre-selected.

    I'd be greatful for any adivce that would allow me to set the value to the
    current data in the cell.

    Thanks

    -- 
    TenDot
    

  • Next message: Ray Costanzo [MVP]: "Re: Setting SelectedDate in <asp:calendar"
    Loading