Learning Curve…

How to bind a DevExpress Scheduler(ASPxScheduler) to SqlDataSource…

Posted on: February 3, 2011

This article illustrates how to bind a DevExpress Scheduler(ASPxScheduler) to SqlDataSource.

In this example, the ASPxSchedulerStorage component (which provides data for the ASPxScheduler control) is bound to SqlDataSource .This SqlDataSource configure with a SQLServer database that stores information about all appointments and resources.

Step -1 Use following sql script to generate two tables to persist appointments and resources data.

CREATE TABLE [dbo].[Appointments] ([UniqueID] [int] IDENTITY (1, 1) NOT NULL ,

[Type] [int] NULL ,

[StartDate] [smalldatetime] NULL ,

[EndDate] [smalldatetime] NULL ,

[AllDay] [bit] NULL ,

[Subject] [nvarchar] (100) NULL ,

[Location] [nvarchar] (50) NULL ,

[Description] [ntext] NULL ,

[Status] [int] NULL ,

[Label] [int] NULL ,

[ResourceID] [int] NULL ,

[ReminderInfo] [ntext] NULL ,

[RecurrenceInfo] [ntext] NULL ,

[CustomField1] [ntext] NULL

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

CREATE TABLE [dbo].[Resources] (

[UniqueID] [int] IDENTITY (1, 1) NOT NULL ,

[ResourceID] [int] NOT NULL ,

[ResourceName] [nvarchar] (50) NULL ,

[Color] [int] NULL ,

[Image] [image] NULL ,

[CustomField1] [ntext] NULL

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

ALTER TABLE [dbo].[Appointments] WITH NOCHECK ADD

CONSTRAINT [PK_Appointments] PRIMARY KEY CLUSTERED

(

[UniqueID]

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Resources] WITH NOCHECK ADD

CONSTRAINT [PK_Resources] PRIMARY KEY CLUSTERED

(

[UniqueID]

) ON [PRIMARY]

GO

Step -2 : Add one ASPxScheduler, two SqlDataSource in a form .Configure SqlDataSource with created tables (Appointments and Resources ). Map ASPxScheduler  with SqlDataSource Data.See Below code:-

Design View :-

<%@ Page Title=”Schedular With SqlDataSource” Language=”C#” MasterPageFile=”~/Site.Master” AutoEventWireup=”true”CodeBehind=”DevExpreessSchedularSql.aspx.cs” Inherits=”Option.DevExpreessSchedularSql” %>

<%@ Register Assembly=”DevExpress.Web.ASPxScheduler.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a”

Namespace=”DevExpress.Web.ASPxScheduler” TagPrefix=”dxwschs” %>

<%@ Register Assembly=”DevExpress.XtraScheduler.v10.2.Core, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a”

Namespace=”DevExpress.XtraScheduler” TagPrefix=”cc1″ %>

<asp:Content ID=”Content1″ ContentPlaceHolderID=”HeadContent” runat=”server”>

</asp:Content>

<asp:Content ID=”Content2″ ContentPlaceHolderID=”MainContent” runat=”server”>

<dxwschs:ASPxScheduler ID=”ASPxScheduler1″ runat=”server”

ActiveViewType=”Month” BackColor=”Aqua”

AppointmentDataSourceID=”SqlDataSourceAppointment” ClientIDMode=”AutoID”

ResourceDataSourceID=”SqlDataSourceResource” Start=”2011-01-31″>

<Storage>

<Appointments>

<Mappings AllDay=”AllDay” AppointmentId=”UniqueID” Description=”Description”

End=”EndDate” Label=”Label” Location=”Location” RecurrenceInfo=”RecurrenceInfo”

ReminderInfo=”ReminderInfo” ResourceId=”ResourceID” Start=”StartDate”

Status=”Status” Subject=”Subject” Type=”Type” />

</Appointments>

<Resources>

<Mappings Caption=”ResourceName” Color=”Color” Image=”Image”

ResourceId=”ResourceID” />

</Resources>

</Storage>

<Views>

<DayView Enabled=”false”>

<TimeRulers>

<cc1:TimeRuler></cc1:TimeRuler>

</TimeRulers>

</DayView>

<WeekView Enabled=”false”></WeekView>

<WorkWeekView Enabled=”false”>

<TimeRulers>

<cc1:TimeRuler></cc1:TimeRuler>

</TimeRulers>

</WorkWeekView>

<TimelineView Enabled=”false”>

</TimelineView>

<MonthView CompressWeekend=”false” DisplayName=”Month”>

</MonthView>

<WorkWeekView Enabled=”false”></WorkWeekView>

</Views>

<OptionsView FirstDayOfWeek=”Monday” />

</dxwschs:ASPxScheduler>

<asp:SqlDataSource ID=”SqlDataSourceAppointment” runat=”server”

ConnectionString=”<%$ ConnectionStrings:Con %>”

DeleteCommand=”DELETE FROM [Appointments] WHERE [UniqueID] = @UniqueID”

InsertCommand=”INSERT INTO [Appointments] ([Type], [StartDate], [EndDate], [AllDay], [Subject], [Location], [Description], [Status], [Label], [ResourceID], [ReminderInfo], [RecurrenceInfo], [CustomField1]) VALUES (@Type, @StartDate, @EndDate, @AllDay, @Subject, @Location, @Description, @Status, @Label, @ResourceID, @ReminderInfo, @RecurrenceInfo, @CustomField1)”

SelectCommand=”SELECT * FROM [Appointments]”

UpdateCommand=”UPDATE [Appointments] SET [Type] = @Type, [StartDate] = @StartDate, [EndDate] = @EndDate, [AllDay] = @AllDay, [Subject] = @Subject, [Location] = @Location, [Description] = @Description, [Status] = @Status, [Label] = @Label, [ResourceID] = @ResourceID, [ReminderInfo] = @ReminderInfo, [RecurrenceInfo] = @RecurrenceInfo, [CustomField1] = @CustomField1 WHERE [UniqueID] = @UniqueID”>

<DeleteParameters>

<asp:Parameter Name=”UniqueID” Type=”Int32″ />

</DeleteParameters>

<InsertParameters>

<asp:Parameter Name=”Type” Type=”Int32″ />

<asp:Parameter Name=”StartDate” Type=”DateTime” />

<asp:Parameter Name=”EndDate” Type=”DateTime” />

<asp:Parameter Name=”AllDay” Type=”Boolean” />

<asp:Parameter Name=”Subject” Type=”String” />

<asp:Parameter Name=”Location” Type=”String” />

<asp:Parameter Name=”Description” Type=”String” />

<asp:Parameter Name=”Status” Type=”Int32″ />

<asp:Parameter Name=”Label” Type=”Int32″ />

<asp:Parameter Name=”ResourceID” Type=”Int32″ />

<asp:Parameter Name=”ReminderInfo” Type=”String” />

<asp:Parameter Name=”RecurrenceInfo” Type=”String” />

<asp:Parameter Name=”CustomField1″ Type=”String” />

</InsertParameters>

<UpdateParameters>

<asp:Parameter Name=”Type” Type=”Int32″ />

<asp:Parameter Name=”StartDate” Type=”DateTime” />

<asp:Parameter Name=”EndDate” Type=”DateTime” />

<asp:Parameter Name=”AllDay” Type=”Boolean” />

<asp:Parameter Name=”Subject” Type=”String” />

<asp:Parameter Name=”Location” Type=”String” />

<asp:Parameter Name=”Description” Type=”String” />

<asp:Parameter Name=”Status” Type=”Int32″ />

<asp:Parameter Name=”Label” Type=”Int32″ />

<asp:Parameter Name=”ResourceID” Type=”Int32″ />

<asp:Parameter Name=”ReminderInfo” Type=”String” />

<asp:Parameter Name=”RecurrenceInfo” Type=”String” />

<asp:Parameter Name=”CustomField1″ Type=”String” />

<asp:Parameter Name=”UniqueID” Type=”Int32″ />

</UpdateParameters>

</asp:SqlDataSource>

<asp:SqlDataSource ID=”SqlDataSourceResource” runat=”server”

ConnectionString=”<%$ ConnectionStrings:con %>”

SelectCommand=”SELECT * FROM [Resources]”></asp:SqlDataSource>

</asp:Content>

Code Behind:-

using System;using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace Option

{

public partial class DevExpreessSchedularSql : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

}

}

Thats it.

View page in browser. You can see existing appointment s. You’re also able to create new appointments, or edit existing ones, and all your changes will be automatically saved to the Database.

Enjoy Coding!!!

Advertisements

4 Responses to "How to bind a DevExpress Scheduler(ASPxScheduler) to SqlDataSource…"

Thanx for the info.. Nice job..

really super:) thanks 4 codings

gud job..thanks for the codings and database

Excelent!!! awesome!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Learning days (Calendar)

February 2011
M T W T F S S
« Jan   Mar »
 123456
78910111213
14151617181920
21222324252627
28  

Knowledge Bank (Archives)

I am on Twitter

Blog Stats

  • 498,756 hits

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 43 other followers

%d bloggers like this: