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

RadScheduler DataStartField and DataEndField is null

1 Answer 64 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Mark de Torres
Top achievements
Rank 1
Mark de Torres asked on 31 Aug 2010, 07:39 AM

I have a problem, where if DataStartFiend and Dataendfield is null in db will throw an exception. Please advise thank you

aspx
<telerik:RadScheduler ID="RadScheduler1" runat="server"
    HoursPanelTimeFormat="htt" ValidationGroup="RadScheduler1" Width="100%" Height="600px"
    MinutesPerRow="5" Skin="Office2007" DayStartTime="08:00:00" DayEndTime="15:00:00" ColumnWidth="200px"
    DataKeyField="ID" DataStartField="Start" DataEndField="End" DataSubjectField="Subject"
    DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentID"
    AllowDelete="false" AllowEdit="false" AllowInsert="false" FirstDayOfWeek="Monday" LastDayOfWeek="Sunday"
    DayHeaderDateFormat="d MMMM yyyy" WeekHeaderDateFormat="d MMMM yyyy" TimelineView-HeaderDateFormat="d MMMM yyyy"
    TimelineView-ColumnHeaderDateFormat="d MMMM yyyy" MonthHeaderDateFormat="MMMM yyyy" SelectedView="WeekView">
   
</telerik:RadScheduler>

aspx.cs

public List<TimetablePeriod> TimetableCollection
{
  set
  {
            RadScheduler1.DataSource = value;
  }
}

TimetablePeriod.cs

 public TimetablePeriod(long studentId,  string startDate, string endDate,
            string weekDay, string startTime, string endTime, string teacherTitle, string roomCode)
        {
            this.studentId = studentId;
            this.startDate = startDate;
            this.endDate = endDate;
            this.weekDay = weekDay;
            this.startTime = startTime;
            this.endTime = endTime;
            this.roomCode = roomCode;
            this.recurParentID = null;
        }

public DateTime Start
        {
            get { return GetDate(startDate, startTime); }
        }

        public DateTime End
        {
            get { return GetDate(startDate, endTime); }
        }

  private DateTime GetDate(string date, string time)
        {
            int year, month, day, hour, minute, second;

            string[] dateParts = date.Split(new char[] { '-' });
            year = Convert.ToInt32(dateParts[0]);
            month = Convert.ToInt32(dateParts[1]);
            day = Convert.ToInt32(dateParts[2]);

            string[] timeParts = time.Split(new char[] { ':' });
            hour = Convert.ToInt32(timeParts[0]);
            minute = Convert.ToInt32(timeParts[1]);
            second = Convert.ToInt32(timeParts[2]);

            DateTime dt = new DateTime(year, month, day, hour, minute, second);
            dt = dt.AddDays(this.GetDayOffset());
            return dt;
        }

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Sep 2010, 01:39 PM
hi Mark de Torres,

DataStartField,DataEndField can't be null.

please see this link    "http://www.telerik.com/help/aspnet-ajax/database-structure.html"     OR    "http://www.telerik.com/help/winforms/sample_database.html"    for DATABASE structure.

   [ID]                    INT IDENTITY(1,1)   NOT NULL,  
   [Subject]               nvarchar(255)       
NOT NULL,  
   [Description]           nvarchar(1024)      
NULL,  
   [Start]                 datetime            
NOT NULL,  
   [End]                   datetime            
NOT NULL,
  
[RecurrenceRule]        nvarchar(1024)      NULL,  
   [RecurrenceParentID]    
INT                 NULL,  
 

i hope this will help u.

let me know if u have any issue.
Tags
Scheduler
Asked by
Mark de Torres
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or