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

Bind in Code Behind

3 Answers 169 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 17 Jul 2008, 04:56 AM
I have looked at the examples and I have not seen an example where I can bind a scheduler in the code behind. For some very odd reason people like to bind using a query in the html.

In any case I am new to the scheduler and want to bind in the code behind. When I try the following code nothing shows on the grid and there should be:

            <telerik:RadScheduler runat="server" ID="RadScheduler1" 
            Width="750px" Skin="Default" EnableEmbeddedSkins="True" 
            SelectedDate="2008-02-02" DayStartTime="08:00:00" DayEndTime="18:00:00" TimeZoneOffset="03:00:00" 
            DataKeyField="AppointmentID" DataSubjectField="Subject" 
            DataStartField="StartDate" DataEndField="EndDate" DataRecurrenceField="RecurrenceRule" 
            DataRecurrenceParentKeyField="RecurrenceParentID">         
              
              
              
            <AppointmentTemplate> 
                <%# Eval("Subject") %> 
            </AppointmentTemplate> 
        </telerik:radscheduler> 


 
    Private Sub BindScheduler()  
 
        Dim dt As DataTable  
 
            dt = '--- get the data table from the SP  ---' 
 
 
 
            If dt.Rows.Count > 0 Then  
                Me.RadScheduler1.DataSource = dt 
                Me.RadScheduler1.DataBind()  
            End If  
 
    End Sub  
 


Any thoughts?

Jason 

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 17 Jul 2008, 12:01 PM
Hi Jason,

Referring to the Database structure topic, here is a code sample how to bind RadScheduler to a datatable:

Protected Sub Page_Load(ByVal sender As ObjectByVal e As EventArgs)  
    If Not IsPostBack Then 
        RadScheduler1.DataKeyField = "ID" 
        RadScheduler1.DataSubjectField = "Subject" 
        RadScheduler1.DataStartField = "Start" 
        RadScheduler1.DataEndField = "End" 
        RadScheduler1.DataRecurrenceField = "RecurrenceRule" 
        RadScheduler1.DataRecurrenceParentKeyField = "RecurrenceParentID" 
        RadScheduler1.DataSource = "MyDataTable" 
        RadScheduler1.DataBind()  
    End If 
End Sub 
 

Don't hesitate to contact us if you have any problems or further questions.


Cheers,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jason
Top achievements
Rank 1
answered on 17 Jul 2008, 01:32 PM
Peter,
thanks for the reply. I am noticing your post and mine and the only difference that I can tell is that you are setting all the properties in the code behind and that you are setting those properties differently. I have the databinding in a function that I call on pageload. Is it requiered to use the values such as 'Start' rather then 'StartDate'?

jason
0
Peter
Telerik team
answered on 17 Jul 2008, 01:56 PM

There is no special requirement as to the names of the datatable columns - they can be anything. I suggest you open a support ticket and send us a simple demo project which we can test locally.
 


Greetings,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Scheduler
Asked by
Jason
Top achievements
Rank 1
Answers by
Peter
Telerik team
Jason
Top achievements
Rank 1
Share this question
or