This is a migrated thread and some comments may be shown as answers.

Binding to a List

4 Answers 84 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 04 Jan 2011, 10:35 PM
I have an object type called a CalendarEvent (it's a Linq2SQL object) that I'm trying to use to populate a Telerik Schedule control (2010.2.292.35). But in spite of everything appearing to work in the code, the schedule control still renders as not having any events at all.

My scenario involves the the events being matches between two sports teams. The user enters an abbreviation(s) for their team in a text box (comma delimited) and I display the games matching the team(s) entered. At the moment I only have two records in the database with the same team code, in this case SW600. So I'm just searching for all events that match that team. My Linq2SQL DAL returns two results as expected and all the values are populated correctly as well. I am using the Linq method ToList() to return the collection as a list since every example I can find for the schedule control using generics uses a List.

Here's the pertinent code as far as I can tell.
Public ReadOnly Property TeamsCodes As String()
    Get
        Return txtTeams.Text.Trim().Replace(" ", "").Split(",")
    End Get
End Property
 
Public ReadOnly Property CalendarEvents() As IList(Of CalendarEvent)
    Get
        If _calendarEvents Is Nothing Then
            _calendarEvents = _dataContext.CalendarEvents.Where(Function(g) g.StartDate.Month = DateTime.Now.Month And TeamsCodes.Contains(g.TeamCode)).ToList()
        End If
        Return _calendarEvents
    End Get
End Property
 
Protected Sub btnBuildCalendar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBuildCalendar.Click
    If (Not String.IsNullOrEmpty(txtTeams.Text)) Then
        rsCalendarEvents.DataSource = CalendarEvents
    End If
End Sub

The aspx code for the control is as follows
<telerik:RadScheduler ID="rsCalendarEvents" runat="server" readonly="true"
    DataKeyField="CalendarEventId" DataSubjectField="EventName" DataDescriptionField="EventDescription"
    DataStartField="StartDate" DataEndField="EndDate" Height="600px">
</telerik:RadScheduler>

Is there something that I'm missing that would explain why this doesn't work for me?

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 06 Jan 2011, 11:15 AM
Hello Nick,

Can you try calling the DataBind() method:
Protected Sub btnBuildCalendar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBuildCalendar.Click
    If (Not String.IsNullOrEmpty(txtTeams.Text)) Then
        rsCalendarEvents.DataSource = CalendarEvents
        rsCalendarEvents.DataBind()   
    End If
End Sub

Other causes for the problem could be the following:

  • If you use RadAjaxManager, you might not have an ajax settings for the button to update RadScheduler.
  • If your RadScheduler is grouped by a resource type, the resource might not be properly associated with the appointment. To verify this, you can handle AppointmentDataBound and examine if this event fires for the expected appointments and what resources they have.

 

Greetings,
Peter
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Nick
Top achievements
Rank 1
answered on 13 Jan 2011, 07:17 PM

Sorry for the delay I haven't had much time to tackle this since my original post. Yes I have tried adding a call to the DataBind() method. It hasn't had any impact at all. We are not using ajax on this page, it's just a typical full page postback. And there are are no grouping settings set on the scheduler either. Is there a set stucture the data source has to have? Most of the examples I have seen on the Telerik site menion gresources or recurrance settings, but ours doesn't use either of these. Would that have any impact on the control? Our CalendarEvent object (which is defined in a Linq2Sql *.dbml file looks something like this.

Partial Public Class CalendarEvent
    Public CalendarEventId As System.Guid
    Public EventType As String
    Public ArenaId As System.Guid
    Public StartDate As Date
    Public EndDate As Date
    Public CustNumber As System.Nullable(Of Integer)
    Public EventNumber As System.Nullable(Of Integer)
    Public DenCode As String
    Public HomeTeam as String
    Public EventName as String
    Public EventDescription as String
End Class
Does that help?
0
Peter
Telerik team
answered on 14 Jan 2011, 05:08 PM
Hi Nick,

We are willing to look deeper into the problem, but we will need a working sample. Please, open a support ticket and send us one.

Best wishes,
Peter
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Nick
Top achievements
Rank 1
answered on 14 Jan 2011, 07:20 PM
Gah! I KNEW it was something simple. While I was creating a sample project to send with a trouble ticket I noticed the EventName field was NULL in the database. As soon as I populated that the events showed up as expected. Though it still strikes me as odd that if the field assigned to DataSubjectField is NULL, the entire record is skipped.
Tags
Scheduler
Asked by
Nick
Top achievements
Rank 1
Answers by
Peter
Telerik team
Nick
Top achievements
Rank 1
Share this question
or