RadCalendar代码有什么问题?

时间:2015-09-08 13:07:31

标签: c# asp.net vb.net visual-studio-2010 telerik

我试图将文本框中提到的逗号分隔日期突出显示为radcalendar

Dim calendar As New RadCalendar()
calendar.SelectionMode = SelectionMode.Extended
calendar.SelectedDates.Add(New DateTime(2008, 7, 7))
calendar.SelectedDates.Add(New DateTime(2008, 7, 8))
calendar.SelectedDates.Add(New DateTime(2008, 10, 10))

在RadCalendar上突出显示文本框逗号分隔日期的代码为03-sep-2015,04-sep-2015

Protected Sub RadCalendar1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadCalendar1.PreRender
    Dim yourCalendar As RadCalendar
    If Page.IsPostBack Then
        If [String].IsNullOrWhiteSpace(TextBox1.Text) = False Then
            'textbox in which dates as stored as comma separated
            Dim datesToShow As String() = TextBox1.Text.Split(","c)
            For Each [date] As String In datesToShow
                yourCalendar.SelectedDates.Add(New DateTime([date]))
            Next
        End If
    End If
End Sub

两个代码都显示错误,蓝色下划线代码为:

类型的值'日期'无法转换为' Telerik.Web.UI.RadDate'。

on yourCalendar.SelectedDates.Add(New DateTime([date]))

1 个答案:

答案 0 :(得分:0)

RadCalendar.SelectedDates.Add方法需要一个类型为“Telerik.Web.UI.RadDate”的属性,并且您传入的是DateTime类型。

您应该新建一个RadDate而不是DateTime。

看起来RadDate的Date属性是DateTime。

所以而不是

data2 %>%
   group_by(ID) %>% 
   mutate(Event1= as.numeric(factor(Event, levels=unique(Event))), 
          count_a= cumsum(Event1==1 & !is.na(Event1)), 
          count_b= cumsum(Event1==2 & !is.na(Event1))) %>%
   select(-Event1)
#    ID Event count_a count_b
#  (int) (int)   (int)   (int)
#1    42    NA       0       0
#2    42     1       1       0
#3    42     2       1       1
#4    42    NA       1       1
#5    42     1       2       1
#6    43    NA       0       0
#7    43     3       1       0
#8    43     4       1       1
#9    43     4       1       2

DO

data <- structure(list(ID = c(42L, 42L, 42L, 42L, 42L, 43L, 43L, 43L, 
43L), Event = c(NA, 1L, 2L, NA, 1L, NA, 1L, 2L, 2L)), .Names = c("ID", 
"Event"), class = "data.frame", row.names = c(NA, -9L))

data2 <- structure(list(ID = c(42L, 42L, 42L, 42L, 42L, 43L, 43L, 43L, 
43L), Event = c(NA, 1L, 2L, NA, 1L, NA, 3L, 4L, 4L)), .Names = c("ID", 
"Event"), row.names = c(NA, -9L), class = "data.frame")