Displayin d/b driven events in RadCalendar for ASPNET Ajax using DayRender event

2 posts, 0 answers
  1. Jeff
    Jeff avatar
    6 posts
    Member since:
    Mar 2008

    Posted 30 Sep 2008 Link to this post

    Hello Community Forum members,

    Please excuse me for my ignorance as I'm new to RadControls and ASP.Net Ajax. MY skill level for ASP.Net is at a high-beginner level, at best.

    I'm trying to display d/b driven events in the RadCalendar control using RADControls for ASPNET Ajax. I can get the Calendar to render properly, but can't seem to get the Events to appear on the scheduled day.

    Here's some background on my project:
    ASP.Net 2.0 using C# and MS Sql 2005 database. After researching these forums and Google, I've discovered that the best way to do this with a calendar control is to make the d/b call once for each month and store the events data from the d/b into an Array or some type of collection vs. making up to 31 calls to the d/b for each day rendered in the month.

    So, after discovering a few examples of how to do this in some older forum posts (previous to the release of RadCalendar for ASPNET Ajax, I believe), I was able to get a head start on how to do this.

    Problem is, I'm running into a few errors at build time re: the DayRender and DefaultViewChanged events:  Telerik.WebControls.Base.Calendar.Events.DayRenderEventArgs

    The compiler throws an error saying:
    Error 143 The type or namespace name 'Base' does not exist in the namespace 'Telerik.WebControls' (are you missing an assembly reference?)

    I looked in the bin directory of my project and all I saw was the following dll's:
    1) RadGrid.dll (used in a previous version of Rad Controls-still works great)
    2) Telerik.Web.UI.dll

    I used the automatic installation to install RadControls to my VS 2005 IDE and it appears fine in the toolbox. In design mode, I inserted the Rad Calendar control on to my page and have customized it from there.

    I keep thinking that there is a way to add a reference/assembly for the Telerik.WebControls.dll to the assemble, but can't locate it anywhere.

    Do I even need the Telerik.WebControls.dll in this version of RadControls for ASP.Net Ajax or will the Telerik.Web.UI.dll do the trick for me?

    If yes, how do I add that reference to my project?

    I've tried several times to add it from the RadControls installation folder at this location:
    C:\Program Files\Telerik\RadControls for ASPNET AJAX Q2 2008\Bin
    but the only dll's and files I saw in there were:
    1) Telerik.Charting.dll
    2) Telerik.Charting.xml
    3) Telerik.Web.UI.dll
    4) Telerik.Web.UI.xml

    I already have the Telerik.Web.UI.dll & Telerik.Web.UI.xml files in the bin directory of my project, but can't seem to get the Telerik.WebControls.dll in there.

    Can anybody help me here? What am I doing wrong?

    And/or - Does anybody have a better suggestion on how to display d/b driven Event data on a RADCalendar for ASP.Net Ajax control?

    Any assistance would be greatly appreciated for this rookie programmer.

    Thanks

    Jeff O'Connell
    jboconne@iupui.edu

    Here is the C# code behind page I'm using for the RadCalendar:

    1 using System;  
    2 using System.Data;  
    3 using System.Data.SqlClient;  
    4 using System.Data.Odbc;  
    5 using System.Configuration;  
    6 using System.Collections;  
    7 using System.Web;  
    8 using System.Web.Security;  
    9 using System.Web.UI;  
    10 using System.Web.UI.WebControls;  
    11 using System.Web.UI.WebControls.WebParts;  
    12 using System.Web.UI.HtmlControls;  
    13 using AnnieECasey.DataBase;  
    14 using AnnieECasey.Lib;  
    15 using Telerik.WebControls;  
    16 using Telerik.Web.UI;  
    17  
    18  
    19  
    20 namespace AnnieECasey  
    21 {  
    22     /// <summary>  
    23     /// Summary description for resources_websites.  
    24     /// </summary>  
    25     public partial class resources_events : System.Web.UI.Page  
    26     {  
    27         public class EventItem  
    28         {  
    29             //===========================================        
    30             // Class used in building the event calendar       
    31             //===========================================       
    32             private int _EventID;  
    33             private System.DateTime _EventDate;  
    34             private string _EventName;  
    35             private string _EventDesc;  
    36             private int _EventCategoryID;  
    37  
    38             public EventItem(int EventID, System.DateTime EventDate, string EventName, string EventDesc, int EventCategoryID)  
    39             {  
    40  
    41                 _EventID = EventID;  
    42                 _EventDate = EventDate;  
    43                 _EventName = EventName;  
    44                 _EventDesc = EventDesc;  
    45                 _EventCategoryID = EventCategoryID;  
    46             }  
    47  
    48             public int EventID  
    49             {  
    50                 get 
    51                 {  
    52                     return _EventID;  
    53                 }  
    54             }  
    55             public System.DateTime EventDate  
    56             {  
    57                 get 
    58                 {  
    59                     return _EventDate;  
    60                 }  
    61             }  
    62             public string EventName  
    63             {  
    64                 get 
    65                 {  
    66                     return _EventName;  
    67                 }  
    68             }  
    69             public string EventDesc  
    70             {  
    71                 get 
    72                 {  
    73                     return _EventDesc;  
    74                 }  
    75             }  
    76             public int EventCategoryID  
    77             {  
    78                 get 
    79                 {  
    80                     return _EventCategoryID;  
    81                 }  
    82             }  
    83  
    84         }  
    85  
    86                         
    87         public void Page_Load(object sender, System.EventArgs e)  
    88         {  
    89             radCalEvents.SelectedDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);  
    90             if (!IsPostBack)  
    91             {  
    92                 GetEventItems();                  
    93             }  
    94         }  
    95  
    96         // setup an array to store all of the events for the month(this is what we will access thru the DayRender event)  
    97         private ArrayList EventArrayList = new ArrayList();  
    98  
    99         public void GetEventItems()  
    100         {  
    101             DateTime startDate = ((MonthView)radCalEvents.CalendarView).MonthStartDate;  
    102             DateTime endDate = ((MonthView)radCalEvents.CalendarView).MonthEndDate;  
    103             SqlDataSource1.SelectParameters["MonthStartDate"].DefaultValue = startDate.ToString();  
    104             SqlDataSource1.SelectParameters["MonthEndDate"].DefaultValue = endDate.ToString();  
    105             SqlDataReader EventReader = ((SqlDataReader)((IEnumerable)SqlDataSource1.Select(DataSourceSelectArguments.Empty)));  
    106  
    107             while (EventReader.Read())  
    108             {  
    109                 EventItem objEvent = new EventItem((int)EventReader["nID"], Convert.ToDateTime(EventReader["dEventDate"]), EventReader["sEventName"].ToString(), EventReader["sEventDescription"].ToString(), (int)EventReader["nEventCategoryID"]);  
    110                 EventArrayList.Add(objEvent);  
    111             }  
    112             EventReader.Close();  
    113             EventReader = null;     
    114                                    
    115         }  
    116  
    117           
    118         protected void radCalEvents_DayRender(object sender, Telerik.WebControls.Base.Calendar.Events.DayRenderEventArgs e)  
    119         {  
    120  
    121             DateTime currentDate = ((Telerik.WebControls.Base.Calendar.Events.DayRenderEventArgs)e).Day.Date;  
    122             Table table = new Table();  
    123             e.Cell.Width = 95;  
    124             table.Width = e.Cell.Width;  
    125             table.Height = e.Cell.Height;  
    126             table.CellPadding = 0;  
    127             table.CellSpacing = 0;  
    128             // Build the row for the day number      
    129             TableRow dateRow = new TableRow();  
    130             TableCell dateCell = new TableCell();  
    131             dateCell.Width = e.Cell.Width;  
    132             dateCell.CssClass = "DayNumber";  
    133  
    134             dateCell.Text = e.Day.Date.Day.ToString();  
    135             dateRow.Cells.Add(dateCell);  
    136             table.Rows.Add(dateRow);  
    137  
    138             // Look in the arraylist for any events on this day     
    139             foreach (EventItem objEvent in EventArrayList)  
    140             {  
    141  
    142                 if (objEvent.EventDate == currentDate)  
    143                 {  
    144  
    145                     // Add a row for the event     
    146                     TableRow itemRow = new TableRow();  
    147                     TableCell itemCell = new TableCell();  
    148  
    149                     itemCell.CssClass = "EventCell";  
    150                     itemCell.Width = e.Cell.Width;  
    151  
    152                     // Set up the hyperlink for the event     
    153                     string itemText = objEvent.EventName;  
    154                     HyperLink itemLink = new HyperLink();  
    155  
    156                     //link to a specific page for details of the event with the eventID as the parameter    
    157                     itemLink.NavigateUrl = "resources_eventDetails.aspx?eventid=" + objEvent.EventID;  
    158                     itemLink.Text = itemText;  
    159                     itemLink.CssClass = "EventLink";  
    160                     itemLink.ToolTip = objEvent.EventDesc;  
    161                     itemCell.Controls.Add(itemLink);  
    162                     itemRow.Cells.Add(itemCell);  
    163                     table.Rows.Add(itemRow);  
    164                       
    165                 }  
    166                    
    167             }  
    168         }  
    169  
    170         protected void radCalEvents_DefaultViewChanged(object sender, Telerik.WebControls.Base.Calendar.Events.DefaultViewChangedEventArgs e)  
    171         {  
    172  
    173             // Select events for the month when the month changes     
    174             GetEventItems();  
    175  
    176         }     
    177  

    and then here is the partial code for the ASPX page:

    <asp:SqlDataSource ID="SqlDataSource1" runat="server"   
                         ConnectionString="<%$ ConnectionStrings:aec_devConnectionString %>"   
                         DataSourceMode="DataReader" SelectCommand="SELECT * FROM [Event] WHERE (([dEventDate] >= @MonthStartDate) AND ([dEventDate] <= @MonthEndDate)) ORDER BY [dEventDate]">     
                            <SelectParameters>    
                                <asp:Parameter Name="MonthStartDate" Type="DateTime" />    
                                <asp:Parameter Name="MonthEndDate" Type="DateTime" />    
                            </SelectParameters>    
                        </asp:SqlDataSource>              
                        <br /> 
                        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
                        </telerik:RadScriptManager> 
                        <br /> 
                        <telerik:radajaxmanager id="RadAjaxManager1" runat="server">  
                            <AjaxSettings> 
                                <telerik:AjaxSetting AjaxControlID="radCalEvents">    
                                    <UpdatedControls> 
                                        <telerik:AjaxUpdatedControl ControlID="radCalEvents"></telerik:AjaxUpdatedControl> 
                                    </UpdatedControls> 
                                </telerik:AjaxSetting> 
                            </AjaxSettings> 
                        </telerik:radajaxmanager> 
                        <telerik:radcalendar id="radCalEvents" runat="server"  OnDayRender="radCalEvents_DayRender" OnDefaultViewChanged="radCalEvents_DefaultViewChanged" font-names="Arial,Verdana,Tahoma" 
                            height="500px" width="700px" ShowRowHeaders="False" Skin="WebBlue" CellAlign="Left" CellVAlign="Top" DayNameFormat="Full" ShowOtherMonthsDays="False" SingleViewRows="7" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" EnableMultiSelect="False" NavigationCellPadding="0" PresentationType="Preview" BorderColor="SteelBlue" BorderStyle="Solid" BorderWidth="1px">  
                            <SelectedDayStyle BackColor="LightSteelBlue" ForeColor="Transparent" /> 
                            <DayStyle BorderStyle="Solid" BorderWidth="1px" Font-Names="Arial" Font-Size="Medium" 
                                Height="100px" Width="100px" Wrap="True" BorderColor="SteelBlue" HorizontalAlign="Left" VerticalAlign="Top" Font-Underline="True" /> 
                            <OtherMonthDayStyle ForeColor="Silver" Wrap="False" BorderColor="SteelBlue" BorderStyle="Solid" BorderWidth="1px" /> 
                            <TitleStyle BackColor="White" BorderColor="Transparent" Font-Names="Verdana" Font-Size="12pt" /> 
                            <WeekendDayStyle BorderStyle="Solid" BorderWidth="1px" Font-Names="Arial" Font-Size="Medium" 
                                Height="100px" VerticalAlign="Top" Width="100px" BorderColor="SteelBlue" HorizontalAlign="Left" Wrap="True" /> 
                            <CalendarTableStyle BorderColor="Transparent" HorizontalAlign="Left"    
                                VerticalAlign="Top" />                                                                                    
                        </telerik:radcalendar> 


     

  2. Mishel
    Mishel avatar
    17 posts
    Member since:
    Jun 2008

    Posted 03 Oct 2008 Link to this post

    Hi Jeff,

    What version of RadCalendar are you using?

    From the code you paste I see that you are using RadCalendar for ASP.NET AJAX. If you need to use this version you do not need any other dll files in your bin folder except Telerik.Web.UI.dll.
    However you this row:
    Telerik.WebControls.Base.Calendar.Events.DayRenderEventArgs ,
    should look like:
    Telerik.Web.UI.Calendar.DayRenderEventArgs

    I hope this helps.

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