RadScheduler - Retrieving values from the SqlDataSource

6 posts, 1 answers
  1. Brad
    Brad avatar
    93 posts
    Member since:
    Jan 2011

    Posted 09 Feb 2011 Link to this post


    I have a RadScheduler populated via an SqlDataSource

    The SELECT statement on the data source is this.

    SqlDataSource1.SelectCommand = "SELECT * FROM [Activity] WHERE act_Rep_ID = " + ScheduleUserID.ToString();

    Simple stuff.

    Now in the AppointmentDateBound event I am trying to set a different color to the appointment, based on a certain value that should be in the appointment thanks to the SELECT * query in the SqlDataSource.

    In this example you can see my test code where I just test the 'Subject'.

    protected void RadScheduler1_AppointmentDataBound(object sender, Telerik.Web.UI.SchedulerEventArgs e)
         {
             Appointment a = e.Appointment;
        
             if (a.Subject == "Phone Call")
             {
                 a.BackColor = System.Drawing.Color.Yellow;
                 a.BorderColor = System.Drawing.Color.Red;
                 a.BorderStyle = BorderStyle.Dotted;
                 a.BorderWidth = Unit.Pixel(2);
             }
         }


    The value I need however is a value that is in the Activity table, but is not listed as a property of the appointment object.

    In fact, the appointment object only holds a fraction of the values from each Activity table row.

    How do I get to all the other values that this SqlDataSource would be holding ?
  2. Brad
    Brad avatar
    93 posts
    Member since:
    Jan 2011

    Posted 11 Feb 2011 Link to this post

    Wow. Over 20 people have looked at this and nobody knows the answer.

    This tells me that it is not possible, or, that it so obvious I should know better.

    In either case, can someone please offer some help?

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 11 Feb 2011 Link to this post

    Hi Brad,

    You'll need to save the selected color in a custom attribute and apply it to the appointment in the AppointmentDataBound event similar to this Demo and the corresponding help article. Otherwise I can not imagine how you will keep the relationship between the "Activity" table and each particular appointment.

    Greetings,
    Veronica Milcheva
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  5. Brad
    Brad avatar
    93 posts
    Member since:
    Jan 2011

    Posted 15 Feb 2011 Link to this post

    Veronica

    This is not about saving the color. It is about setting a color based on value that for some reason I can't get out of the SqlDataSource.

    It is also nothing to do with the Advanced Edit Form.

    I'll be more specific

    First, an Activity IS an appointment in my DB.

    Each appointment in my Activity table has an act_Location_ID.

    I need to get this act_Location_ID value out of the SqlDataSource as each appointment is written. I know were to put the code, I know how to set the color, what I don't have is the value from each activity to test.

    You can see in my code below, I doing this.

    if (a.Subject == "Phone Call")
    {
     
    }

    What I need to be able to do is this...

    if (a.act_Location_ID == 0)
    {
     
    }

    How do I get the act_Location_ID?
  6. Answer
    Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 18 Feb 2011 Link to this post

    Hello Brad,

    As I understand the act_Location_ID is an additional field in the Activity table which is not related directly to the appointments (it is neither Start, End, Subject, ID, etc.). So my suggestion for you is to create a Custom Attribute and keep it's values in the act_Location_ID field. That way you can easily check the value via the Appointment object:

    a.Attributes["activity_location"] == "0"
            {
                ...
            }

    Regards,
    Veronica Milcheva
    the Telerik team
  7. Brad
    Brad avatar
    93 posts
    Member since:
    Jan 2011

    Posted 20 Feb 2011 Link to this post

    DIng! That did the trick Veronica.

    Thank you so much for your help.

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