Hi, i m new in Telerik, i just starting to learn how to use the scheduler to create an appointment system.
Actually my problem is: in my database, it used separate date("dd/mm/yyyy") and time("11/11/1766" hh:mm) to record the current appointment datetime, i cannot simply used Data Source Configuration Wizard to bind two separate data fields in each Start/End time fields, also, i am not allow to custom my database record format... is it anyway/possibility can bind two data in one single field? Or Radscheduler can make any custom setting to bind multiple data? Thx.
Actually my problem is: in my database, it used separate date("dd/mm/yyyy") and time("11/11/1766" hh:mm) to record the current appointment datetime, i cannot simply used Data Source Configuration Wizard to bind two separate data fields in each Start/End time fields, also, i am not allow to custom my database record format... is it anyway/possibility can bind two data in one single field? Or Radscheduler can make any custom setting to bind multiple data? Thx.
5 Answers, 1 is accepted
0
Accepted
Hi Chan,
You can create a new DataSet and merget the date and time fields. Here is an example:
Attached is a sample for reference.
You can also take a look at the online documentation linked below, concerning RadScheduler's binding to a data source: RadScheduler Data binding.
Binding two columns of a data base table to a single data container is rather unnecessary. The documentation linked above, explains in details the structure of a data base to which a RadScheduler control could be bound.
The online populating with data demos of the RadScheduler, might be of help, too.
All the best,
Ivana
the Telerik team
You can create a new DataSet and merget the date and time fields. Here is an example:
protected
void
Page_Load(
object
sender, EventArgs e)
{
SqlDataAdapter custAdapter =
new
SqlDataAdapter(@
"SELECT * FROM [AppointmentTestTable]"
, @
"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Telerik.mdf;Integrated Security=True;User Instance=True"
);
DataSet DS =
new
DataSet();
custAdapter.Fill(DS,
"AppointmentsTestTable"
);
DataColumn start =
default
(DataColumn);
DataColumn end =
default
(DataColumn);
start =
new
DataColumn(
"Start"
, System.Type.GetType(
"System.DateTime"
));
end =
new
DataColumn(
"End"
, System.Type.GetType(
"System.DateTime"
));
DS.Tables[
"AppointmentsTestTable"
].Columns.Add(start);
DS.Tables[
"AppointmentsTestTable"
].Columns.Add(end);
foreach
(DataRow dr
in
DS.Tables[
"AppointmentsTestTable"
].Rows)
{
dr[
"Start"
] = ((DateTime)dr[
"StartDate"
]).Add((TimeSpan)dr[
"StartTime"
]);
dr[
"End"
] = ((DateTime)dr[
"StartDate"
]).Add((TimeSpan)dr[
"EndTime"
]);
}
RadScheduler1.DataSource = DS;
RadScheduler1.DataKeyField =
"ID"
;
RadScheduler1.DataSubjectField =
"Subject"
;
RadScheduler1.DataStartField =
"Start"
;
RadScheduler1.DataEndField =
"End"
;
RadScheduler1.DataBind();
}
Attached is a sample for reference.
You can also take a look at the online documentation linked below, concerning RadScheduler's binding to a data source: RadScheduler Data binding.
Binding two columns of a data base table to a single data container is rather unnecessary. The documentation linked above, explains in details the structure of a data base to which a RadScheduler control could be bound.
The online populating with data demos of the RadScheduler, might be of help, too.
All the best,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Accepted
Pablo
Top achievements
Rank 1
answered on 06 Dec 2011, 09:04 PM
Hi Chan,
I'm assuming you are using SQL Server 2008 because you have two separate fields. What you can do is the following in your select query for the appointments where Start_Date & End_Date are a DATE datatype and End_Time & Start_Time are TIME datatype:
SELECT (CAST(START_DATE AS DATETIME) + START_TIME) AS Start, (CAST(END_DATE AS DATETIME) + END_TIME) AS End
FROM YOUR_TABLE
Thanks
I'm assuming you are using SQL Server 2008 because you have two separate fields. What you can do is the following in your select query for the appointments where Start_Date & End_Date are a DATE datatype and End_Time & Start_Time are TIME datatype:
SELECT (CAST(START_DATE AS DATETIME) + START_TIME) AS Start, (CAST(END_DATE AS DATETIME) + END_TIME) AS End
FROM YOUR_TABLE
Thanks
0
Hello Chan,
Pablo is right, his suggestion is just another way to access the data from the data source and combine the two fields into one. I have modified the sample project; you could download it and try it locally.
I hope this helps.
Kind regards,
Ivana
the Telerik team
Pablo is right, his suggestion is just another way to access the data from the data source and combine the two fields into one. I have modified the sample project; you could download it and try it locally.
I hope this helps.
Kind regards,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Chan
Top achievements
Rank 1
answered on 09 Dec 2011, 09:30 AM
THX master Ivana and Pablo, it was great help to me!
0
Hi Chan,
Indeed, it will work, but you need to use this code:
Kind regards,
Peter
the Telerik team
Indeed, it will work, but you need to use this code:
protected
void
Page_Load(
object
sender, EventArgs e)
{
SqlDataAdapter custAdapter =
new
SqlDataAdapter(@"SELECT CAST(StartDate AS DATETIME) + StartTime AS StartDate, Subject, ID, CAST(EndDate AS DATETIME) + EndTime AS EndDate
FROM [AppointmentTestTable]
", @"
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Telerik.mdf;Integrated Security=True;User Instance=True");
DataSet DS =
new
DataSet();
custAdapter.Fill(DS,
"AppointmentsTestTable"
);
RadScheduler1.DataSource = DS;
RadScheduler1.DataKeyField =
"ID"
;
RadScheduler1.DataSubjectField =
"Subject"
;
RadScheduler1.DataStartField =
"StartDate"
;
RadScheduler1.DataEndField =
"EndDate"
;
RadScheduler1.DataBind();
}
Kind regards,
Peter
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now