繁体   English   中英

RadCalendar代码有什么问题?

[英]Whats wrong with that RadCalendar Code?

我正在尝试向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的2015年9月3日,2015年9月4日

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

这两个代码都在两个代码上显示了带有蓝色下划线的错误:

类型“ Date”的值不能转换为“ Telerik.Web.UI.RadDate”。

在yourCalendar.SelectedDates.Add(New DateTime([date]))上

线

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

您应该更新RadDate而不是DateTime。

看起来RadDate具有一个Date属性,它是一个DateTime。

所以代替

calendar.SelectedDates.Add(New DateTime(2008,7,7));

Dim d = New RadDate()
d.Date = New DateTime(2008, 7, 7)
calendar.SelectedDates.Add(d)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM