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

How to access row that is about to get inserted in RadScheduler1_AppointmentInsert event

8 Answers 105 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 26 Aug 2011, 01:06 PM
Hi

Sorry but must say that i find documentation not very useful for simpler tasks.  its becomes quite frustating.

Following is my table created to store appointments.    DataSourceID is set to "SqlDataSource1"
Now inside RadScheduler1_AppointmentInsert event,  through code I want to add values for columns Importance and Loginid
How can i access Row that is about to get inserted ?

Regards

CREATE TABLE [dbo].[TaskSchedules](
 [keyid] bigint NOT NULL PRIMARY KEY Identity,
 [StartTime] [datetime] NULL,
 [EndTime] [datetime] NULL,
 [Subject] [nvarchar](max) NULL,
 [Description] [nvarchar](max) NULL,
 [Reminders] [nvarchar](max) NULL,
 [Recurrence] [nvarchar](max) NULL,
 [RecurrenceParentKey] bigint NULL 
 [Importance] [nvarchar](2) NULL,
 [LoginId]   [nvarchar](30) NOT NULL
)

8 Answers, 1 is accepted

Sort by
0
Dan Lehmann
Top achievements
Rank 1
answered on 26 Aug 2011, 07:42 PM
Can you paste the asp for your Scheduler?
0
Lee
Top achievements
Rank 1
answered on 26 Aug 2011, 08:22 PM
Here is html source of scheduler.

     <telerik:RadScheduler ID="RadScheduler1" runat="server"
            DataDescriptionField="Description" DataEndField="EndTime" DataKeyField="keyid"
            DataRecurrenceField="Recurrence"
            DataRecurrenceParentKeyField="RecurrenceParentKey"
            DataReminderField="Reminders" DataSourceID="SqlDataSource1"
            DataStartField="StartTime" DataSubjectField="Subject"
            EnableDescriptionField="True" FirstDayOfWeek="Monday" SelectedView="MonthView"
            Skin="Sitefinity"  OverflowBehavior="Expand" RowHeaderWidth="50px"
            RowHeight="25px" CustomAttributeNames="Categorize,Importance"
            EnableCustomAttributeEditing="True"
            onappointmentinsert="RadScheduler1_AppointmentInsert"
            StartEditingInAdvancedForm="False"   >
            <AdvancedForm EnableCustomAttributeEditing="True" />
            <Reminders Enabled="True" />
        </telerik:RadScheduler>
0
Dan Lehmann
Top achievements
Rank 1
answered on 26 Aug 2011, 08:32 PM
Only thing that jumps out at me is CustomAttributeNames="Categorize,Importance". Would that need to be CustomAttributeNames="Loginid,Importance".

How are you binding your data?
0
Veronica
Telerik team
answered on 28 Aug 2011, 01:26 PM
Hi Raghu,

As the LoginId and Importance are addional fields to the Appointment table - you can not access them directly via e.Appointment class in the OnAppointmentInsert event. Instead you can add them to the custom attributes collection of the RadScheduler and further access them in the way shown below:
protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
       {
           e.Appointment.Attributes["LoginId"] = DateTime.Now.ToString();
       }

Please take a look at this demo for a full example of custom attributes.

Regards,
Veronica Milcheva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Lee
Top achievements
Rank 1
answered on 28 Aug 2011, 07:47 PM
Hi Veronica,

Sorry for the confusion,  please ignore CustomAttributeNames.  They exists because i was trying something. ignore it.

Still my main question is "How to access Row that is about to get inserted "  so that i can fill values for other columns of the table.
I understand and do not wish to access "addional fields to the Appointment table via e.Appointment class".
But there has to be some other object or workaround.

Regards

0
Veronica
Telerik team
answered on 29 Aug 2011, 06:56 AM
Hi Raghu,

Unfortunately I think that there is still an misunderstanding.

As I understand - you want to add values to the LoginId and Importance fields in the OnAppointmentInsert event. However as they are part of the Appointment table - the only way to get those fields in the OnAppointmentInsert event is by adding them as a custom attributes to the RadScheduler. If you don't want the textbox to be applied in the Advanced Form (as for each custom attribute added one textbox is added to the advanced form on insert / edit ) - you can set the AdvancedForm-EnableCustomAttributeEditing property to false.

Please let me know if I got your requirement.

All the best,
Veronica Milcheva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Lee
Top achievements
Rank 1
answered on 31 Aug 2011, 08:35 PM
Hi,

Thanks for reply.   Ya there was little confusion, maybe i was not able to express my query.

Lets say if database column names and attributes name are matching and if in RadScheduler1_AppointmentInsert
we assign values to attributes, will it automatically get stored into respective fields in database?

Regards


However I found a workaround to manipulate values in SqlDataSource1_Inserting  event.
by editing e.command's parameter values.




0
Veronica
Telerik team
answered on 01 Sep 2011, 07:48 AM
Hello Lee,

I'm glad that you found a workaround and yes - if you assign values of the custom attributes in the OnAppointmentInsert event you will get them stored in the corresponding database fields.

Greetings,
Veronica Milcheva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Scheduler
Asked by
Lee
Top achievements
Rank 1
Answers by
Dan Lehmann
Top achievements
Rank 1
Lee
Top achievements
Rank 1
Veronica
Telerik team
Share this question
or