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

9 posts, 0 answers
  1. Lee
    Lee avatar
    48 posts
    Member since:
    Feb 2010

    Posted 26 Aug 2011 Link to this post

    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
    )
  2. Dan Lehmann
    Dan Lehmann avatar
    103 posts
    Member since:
    May 2011

    Posted 26 Aug 2011 Link to this post

    Can you paste the asp for your Scheduler?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Lee
    Lee avatar
    48 posts
    Member since:
    Feb 2010

    Posted 26 Aug 2011 Link to this post

    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>
  5. Dan Lehmann
    Dan Lehmann avatar
    103 posts
    Member since:
    May 2011

    Posted 26 Aug 2011 Link to this post

    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?
  6. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 28 Aug 2011 Link to this post

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

  7. Lee
    Lee avatar
    48 posts
    Member since:
    Feb 2010

    Posted 28 Aug 2011 Link to this post

    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

  8. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 29 Aug 2011 Link to this post

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

  9. Lee
    Lee avatar
    48 posts
    Member since:
    Feb 2010

    Posted 31 Aug 2011 Link to this post

    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.




  10. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 01 Sep 2011 Link to this post

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

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017