Calendar Control PRoblem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Laz

    #1

    Calendar Control PRoblem

    I need some assistance.

    I am getting the error "Conversion from type 'DBNull' to type 'Date' is
    not valid." while rendering the edit template column of a calendar
    control where the SQL field is null.

    Here is the column code:
    <ASP:TemplateCo lumn HEADERTEXT="Pla nned Date"
    ITEMSTYLE-HORIZONTALALIGN ="Center">
    <ItemTemplate >
    <%# String.Format(" {0:d}", DataBinder.Eval
    (Container.Data Item, "WISP_Upgrade_P lanned_Date")) %>
    </ItemTemplate>
    <EditItemTempla te>
    <ASP:Calendar ID="plannedDate " RUNAT="Server"
    SelectedDate='< %# CheckDate(DataB inder.Eval
    (Container.Data Item, "WISP_Upgrade_P lanned_Date")) %>'
    VisibleDate='<% # CheckDate(DataB inder.Eval
    (Container.Data Item, "WISP_Upgrade_P lanned_Date")) %>'/>
    </EditItemTemplat e>
    </ASP:TemplateCol umn>

    As you can see, I tried creating a function that supplies a date value
    of Now() if the column is null.

    Function CheckDate(Selec tedDate As DateTime)
    If IsDBNull(Select edDate) Then
    Return Now()
    Else
    Return SelectedDate
    End If
    End Function

    But IIS never gets to even try the function as the error happens BEFORE
    the function is executed.


    Please advise.

    Thanks

Working...