Learning Curve…

Archive for the ‘DevExpress’ Category

If your are using DevExpress Controls ,This issue can be resolved with following steps :-

1. Add Namspace  – DevExpress.Web.ASPxClasses;

2.Instead of passing you navigation string in response.redirect function use ASPxWebControl.RedirectOnCallback method.

Example :- ASPxWebControl.RedirectOnCallback(UrURLString);

Advertisements

Add below code in in Page_Load

  ASPxGridLookup1.GridView.Width = ASPxGridLookup1.Width;

where ASPxGridLookup1 is ASPxGridLookup’s id.

Step  to get  value (id) of selected row in ASPxGridLookup  from the client side event : –

1 . Write a JavaScript function :

[JScript]

var key = gridLookup.GetGridView().GetRowKey(gridLookup.GetGridView().
GetFocusedRowIndex());
(where gridLookup is ASPxGridLookup ‘s id).
 2.  Call this function on ASPxGridLookup’s client click events.thats it… :):)

This article illustrates how to handle DevExpress Scheduler(ASPxScheduler) with  CLSA.

In this example, the ASPxSchedulerStorage component (which provides data for the ASPxScheduler control) is bound to ObjectDataSource  that gets data from CSLA classes , and CSLA classes are  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 : Generate CSLA Editable classes (EditableRoot and EditableRootList ) with [dbo].[Appointments] table and ReadOnly Classes (ReadOnlyList and ReadOnlyRoot)  with [dbo].[Resources] table respectively.

Step -3 : Add one ASPxScheduler, two ObjectDataSource in a form .Configure ObjectDataSource  with created Classes  to get data from database. Map ASPxScheduler  with ObjectDataSource Data and then In code Behind you need to do some coding to insert , update and delete appointments.

See Below code:-

Design View :-

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

<%@ 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=”Content3″ ContentPlaceHolderID=”HeadContent” runat=”server”>

</asp:Content>

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

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

AppointmentDataSourceID=”ObjectDataSourceAppoitment” ResourceDataSourceID=”ObjectDataSourceResource”

ClientIDMode=”AutoID” OnAppointmentInserting=”ASPxScheduler1_AppointmentInserting”

OnAppointmentRowDeleting=”ASPxScheduler1_AppointmentRowDeleting” OnAppointmentRowUpdating=”ASPxScheduler1_AppointmentRowUpdating” Start=”2011-01-31″>

<Views>

<DayView Enabled=”false”>

<TimeRulers>

<cc1:TimeRuler />

</TimeRulers>

</DayView>

<WorkWeekView Enabled=”false”>

<TimeRulers>

<cc1:TimeRuler />

</TimeRulers>

</WorkWeekView>

<WeekView Enabled=”false”>

</WeekView>

<TimelineView Enabled=”false” />

<MonthView CompressWeekend=”False” >

</MonthView>

</Views>

<Storage EnableReminders=”false”>

<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>

<OptionsView FirstDayOfWeek=”Monday” />

</dxwschs:ASPxScheduler>

<asp:ObjectDataSource ID=”ObjectDataSourceAppoitment” runat=”server” TypeName=”Library.AppointmentList”

SelectMethod=”GetAll”></asp:ObjectDataSource>

<asp:ObjectDataSource ID=”ObjectDataSourceResource” runat=”server” SelectMethod=”GetAll”

TypeName=”Library.ResourceInfoList”></asp:ObjectDataSource>

</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;

using Library;

using DevExpress.Web.ASPxScheduler;

using DevExpress.XtraScheduler;

using DevExpress.XtraScheduler.Xml;

namespace Option

{

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

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void ASPxScheduler1_AppointmentInserting(object sender, PersistentObjectCancelEventArgs e)

{

try

{

e.Cancel = true;

DevExpress.XtraScheduler.Appointment apt = (DevExpress.XtraScheduler.Appointment)e.Object;

Library.Appointment AddAppointment = Library.Appointment.NewAppointment();

AddAppointment.BeginEdit();

AddAppointment.AllDay = apt.AllDay;

AddAppointment.StartDate = apt.Start;

AddAppointment.EndDate = apt.End;

AddAppointment.Subject = apt.Subject;

AddAppointment.Description = apt.Description;

AddAppointment.Label = apt.LabelId;

AddAppointment.Location = apt.Location;

AddAppointment.Status = apt.StatusId;

if (apt.Reminder != null)

{

ReminderCollectionXmlPersistenceHelper helper = new ReminderCollectionXmlPersistenceHelper(apt, DateSavingType.UTC);

AddAppointment.ReminderInfo = helper.ToXml();

}

if (apt.RecurrenceInfo != null)

{

RecurrenceInfoXmlPersistenceHelper helper = new RecurrenceInfoXmlPersistenceHelper(apt.RecurrenceInfo, DateSavingType.UTC);

AddAppointment.RecurrenceInfo = helper.ToXml();

}

if (apt.ResourceIds != null)

{

DevExpress.XtraScheduler.Xml.AppointmentResourceIdCollectionXmlPersistenceHelper helper = new DevExpress.XtraScheduler.Xml.AppointmentResourceIdCollectionXmlPersistenceHelper(apt.ResourceIds);

string resourceIds = helper.ToXml();

helper = new DevExpress.XtraScheduler.Xml.AppointmentResourceIdCollectionXmlPersistenceHelper(new ResourceIdCollection());

ResourceIdCollection collection = helper.FromXml(resourceIds) as ResourceIdCollection;

int resId = 0;

foreach (object resourceId in collection)

{

resId = Convert.ToInt32(resourceId);

AddAppointment.ResourceID = resId;

}

}

AddAppointment.Type = (Int32)apt.Type;

AddAppointment.IsArchive = false;

AddAppointment.IsDeleted = false;

AddAppointment.ApplyEdit();

AddAppointment.Save();

ASPxSchedulerStorage storage = (ASPxSchedulerStorage)sender;

storage.RefreshData();

ASPxScheduler1.DataBind();

}

catch (Exception ex)

{

Response.Write(ex.Message);

}

}

protected void ASPxScheduler1_AppointmentRowDeleting(object sender, ASPxSchedulerDataDeletingEventArgs e)

{

try

{

e.Cancel = true;

Int32 UniqueID = Convert.ToInt32(e.Keys[“UniqueID”]);

Library.Appointment.IsDeleteALLAppointment(false, UniqueID);

ASPxScheduler1.DataBind();

}

catch (Exception ex)

{

Response.Write(ex);

}

}

protected void ASPxScheduler1_AppointmentRowUpdating(object sender, ASPxSchedulerDataUpdatingEventArgs e)

{

try

{

e.Cancel = true;

Int32 UniqueID = Convert.ToInt32(e.Keys[“UniqueID”]);

if (UniqueID != 0)

{

Library.Appointment Updateppointment =   Library.Appointment.GetByUniqueID(UniqueID);

Updateppointment.BeginEdit();

Updateppointment.AllDay = Convert.ToBoolean(e.NewValues[“AllDay”]);

Updateppointment.StartDate = Convert.ToDateTime(e.NewValues[“StartDate”]);

Updateppointment.EndDate = Convert.ToDateTime(e.NewValues[“EndDate”]);

Updateppointment.Subject = Convert.ToString(e.NewValues[“Subject”]);

Updateppointment.Description = Convert.ToString(e.NewValues[“Description”]);

Updateppointment.Label = Convert.ToInt32(e.NewValues[“Label”]);

Updateppointment.Location = Convert.ToString(e.NewValues[“Location”]);

Updateppointment.Status = Convert.ToInt32(e.NewValues[“Status”]);

Updateppointment.Type = Convert.ToInt32(e.NewValues[“Type”]);

Updateppointment.IsArchive = false;

Updateppointment.IsDeleted = false;

Updateppointment.ApplyEdit();

Updateppointment.Save(true);

ASPxScheduler1.DataBind();

}

}

catch (Exception ex)

{

Response.Write(ex.Message);

}

}

}

}

Thats it.

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

Enjoy Coding!!!

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!!!


Author

Learning days (Calendar)

December 2017
M T W T F S S
« Jun    
 123
45678910
11121314151617
18192021222324
25262728293031

Knowledge Bank (Archives)

I am on Twitter

Blog Stats

  • 520,020 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: