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

[Solved] Passing Event Details Based on Apt. Click?

3 Answers 184 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
TSCGlobal
Top achievements
Rank 1
TSCGlobal asked on 01 Feb 2008, 03:43 PM
Hello:

I've been working with your schedular for a few days. One thing that I need is to be able to see the event details based upon an appointment/event a user clicks on (will be read-only).  I noticed the apointmenClick event, and I know I want to get the appointment's EventDescription WHERE @ID=EventID (or something like that). Then I want to display it in a label (me.lvlEventDetail.Text)

The issue I am having is as follows:

1. Is this possible?
2. If so, what would the syntax look like?

I had a thought to simply show the event detail in a table below the schedular, or (and I like this idea better) use RadTooltip to show event details and provide a link for registration.

I look forward to your response.

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 04 Feb 2008, 10:00 AM
Hello Duane,

The event argument of OnClientAppointmentClick event has the get_appoinment() method which returns a client object of the clicked appointment. Furthermore, the client appoinment object has properties such as Subject, ID, Start and End which will allow you to get the details you need for this case. Here is a simple example:

<script type="text/javascript">  
                function ClientAppointmentClickHandler(sender, eventArgs)  
        {  
            var eventDescription = eventArgs.get_appointment().Subject;  
            alert(eventDescription);  
              
        }  
        </script> 
        
        <telerik:RadScheduler ID="RadScheduler1" 
                  OnClientAppointmentClick="ClientAppointmentClickHandler" ... /> 

Should you have any other questions, please fee free to contact us.


Regards,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
TSCGlobal
Top achievements
Rank 1
answered on 04 Feb 2008, 05:28 PM
Ok, based on your response, I took a slighly different approach. It seems to be pretty solid syntax-wise, but I received the following error:

Conversion failed when converting the nvarchar value 'EventID' to data type int

After doing a bit more research, I modified the code as follows:

------------------------------------

Protected Sub RadScheduler1_AppointmentClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerEventArgs) Handles RadScheduler1.AppointmentClick

Dim EventID

Dim conn As New SqlConnection()

'Make DataKeyField in RadScheduler Integer

EventID =

Integer.Parse(Me.RadScheduler1.DataKeyField)

' SQL Connection String Event
conn.ConnectionString = "Data Source=xxxx.domain.com;Initial Catalog=DBNAME;Persist Security Info=True;User ID=username;Password=password"

'open connection
conn.Open()

'SQL SELECT statement
Dim cmd As New SqlCommand

cmd.CommandType = CommandType.Text
cmd.CommandText =

"SELECT EventName, EventDescription FROM dummytable WHERE EventID = @EventID"
cmd.Connection = conn

' Create a SqlParameter for each parameter in the stored procedure.
cmd.Parameters.AddWithValue("@EventID", EventID)

'Execute Reader
Dim Reader As SqlDataReader = cmd.ExecuteReader()

While
Reader.Read()
    Me.lblEventName.Text = Reader("EventName").ToString
    Me.lblEventDetail.Text = Reader("EventDetail").ToString
End While

Reader.Close()

conn.Close()

End Sub

The problem I have now is the following error message:

Input string was not in a correct format.

And it points out the following line:

Line 12:         'Make DataKeyField in RadScheduler Integer
Line 13:         EventID = Convert.ToInt32(Me.RadScheduler1.DataKeyField)
Line 14:


0
Accepted
T. Tsonev
Telerik team
answered on 07 Feb 2008, 01:27 PM
Hello Duane,

The RadScheduler1.DataKeyField is actually the name of the database column that contains the primary key. The event ID can be accessed from the Appointment passed in the SchedulerEventArgs:

EventID = CType(e.Appointment.ID,Integer


Greetings,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Scheduler
Asked by
TSCGlobal
Top achievements
Rank 1
Answers by
Peter
Telerik team
TSCGlobal
Top achievements
Rank 1
T. Tsonev
Telerik team
Share this question
or