Update Radgrid update on OnClientTimeSlotClickHandler

10 posts, 0 answers
  1. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 29 Nov 2010 Link to this post

    I have a radgrid which contains extended information that I would like to display based on a date clicked on RadScheduler. I can get the grid to perform the refresh using the OnClientTimeSlotClickHandler and the RadAjaxManager, however, the date is not being passed to the SQLDataSource that the grid uses so no data is diplayed in the grid. Any help would be appreciated.

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">       
    <script type="text/javascript"
        function OnClientTimeSlotClickHandler(sender, eventArgs) { 
            if (sender.get_selectedView() == Telerik.Web.UI.SchedulerViewType.MonthView) { 
                $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest(eventArgs.get_time().format("MM/dd/yyyy")); 
            
        }           
    </script>      
    </telerik:RadCodeBlock>  
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
                <ajaxsettings
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
                        <updatedcontrols
                            <telerik:AjaxUpdatedControl ControlID="sds_SubRequests" UpdatePanelHeight="" /> 
                        </updatedcontrols
                    </telerik:AjaxSetting
                    <telerik:AjaxSetting AjaxControlID="RadCodeBlock1"
                        <updatedcontrols
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                        </updatedcontrols
                    </telerik:AjaxSetting
                </ajaxsettings
            </telerik:RadAjaxManager
    <asp:SqlDataSource ID="sds_SubRequests" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Human_ResourcesConnectionString %>"  
        SelectCommand="SELECT [DateSubNeeded], [Reason], [Location], [FullName], [OU], [Telephone1] FROM [vw_SCS_SubRequests] WHERE ([DateSubNeeded] = @DateSubNeeded)"> 
        <SelectParameters
            <asp:Parameter Name="clickedDateTime" Type="DateTime" /> 
        </SelectParameters
    </asp:SqlDataSource>

    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) 
        RadScheduler1.SelectedDate = DateTime.Parse(e.Argument) 
        RadScheduler1.SelectedView = SchedulerViewType.DayView 
        sds_SubRequests.SelectParameters("clickedDateTime").DefaultValue = RadScheduler1.SelectedDate 
    End Sub





  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 02 Dec 2010 Link to this post

    Hi Allan,

    In the Ajax_Request server event you need to call the grid's rebind method. Furthermore, remove the following ajax setting:

    <telerik:AjaxSetting AjaxControlID="RadCodeBlock1">  
        <updatedcontrols>  
            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />  
        </updatedcontrols>  
    </telerik:AjaxSetting>  

    and replace it with:

    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">  
        <updatedcontrols>  
            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />  
        </updatedcontrols>  
    </telerik:AjaxSetting>  


    Hope it helps.


    Regards,
    Tsvetoslav
    the Telerik team
    Browse the vast support resources we have to jumpstart 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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 02 Dec 2010 Link to this post

    Thank you for the reply. I made the requested changes, however this does not seem to correct the issue. Here is my complete code:

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="availability_calendar.aspx.vb" Inherits="_Default" %>
    <%@ Register Assembly="Telerik.Web.UI, Version=2010.2.713.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
        Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
    <head id="Head1" runat="server">
        <title>TUSD - Substitute Calender System</title>
        <link rel="stylesheet" type="text/css" href="~/includes/ITC_Main.css" /> 
        <link rel="stylesheet" type="text/css" href="~/includes/Scheduler.Default.css" /> 
      
    </head>
    <body>
        <form id="form1" runat="server">
      
      
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">      
        <script type="text/javascript">
            function OnClientTimeSlotClickHandler(sender, eventArgs) {
                if (sender.get_selectedView() == Telerik.Web.UI.SchedulerViewType.MonthView) {
                    $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest(eventArgs.get_time().format("MM/dd/yyyy"));
                }
            }          
        </script>     
        </telerik:RadCodeBlock
      
      
      
        <div id="header">
      
            <table cellpadding="0" cellspacing="0" style="width: 100%; height: 40px;">
                <tr>
                    <td style="text-align: center; width: 339px; vertical-align: middle;">
                        <img alt="" src="../images/scslogo.png" style="width: 300px; height: 35px" /></td>
                    <td style="width: 211px; text-align: center">
                        <datelbl:ShowDate ID="ShowDate1" runat="server" />
                    </td>
                    <td style="text-align: right; vertical-align: middle;">
                        <table cellpadding="2" cellspacing="0" 
                              
                            style="width: 292px; height: 40px; background-image: url('../images/headerinset.gif'); text-align: center;">
                            <tr>
                                <td style="font-weight: bold; font-size: small; font-family: Arial, Helvetica, sans-serif; color: #00B000; text-align: center;">
                                    Logged in as: 
                                    <asp:LoginName ID="LoginName1" runat="server" Font-Names="Arial" 
                                        Font-Size="Small" ForeColor="#597791" />
                                         
                                    <asp:LoginStatus ID="LoginStatus1" runat="server" CssClass="login" />
                                </td>
                            </tr>
                        </table></td>
                    <td style="text-align: right; vertical-align: middle;">
                        <img alt="" src="../images/logo_tusd_itc.gif" style="width: 152px; height: 36px" /></td>
                </tr>
            </table>
      
        </div>
            <div id="subheader">
      
        </div>
                <div>
            <table cellpadding="0" cellspacing="0" style="width: 100%">
                <tr>
                    <td valign="top" 
                        style="background-color: #FFFFFF; border-bottom-style: solid; border-bottom-width: thin; border-bottom-color: #000000;">
        <table cellpadding="0" cellspacing="0" style="width: 1000px">
            <tr>
                <td style="width: 230px; vertical-align: top; background-color: #E6E6E6;">
                    <telerik:RadPanelBar ID="rpb_SCS" Runat="server" DataFieldID="DataFieldID" 
                            DataFieldParentID="DataFieldParentID" 
                            DataNavigateUrlField="DataNavigateUrlField" DataSourceID="sds_SCS_MenuConsole" 
                            DataTextField="DataTextField" DataValueField="DataTextField" Width="250px" 
                            PersistStateInCookie="True" Skin="Default">
                        </telerik:RadPanelBar></td>
                <td style="vertical-align: top;">
                    <table cellpadding="0" cellspacing="0" style="width: 100%">
                        <tr>
                            <td style="padding: 10px">
                                    <h5>
                                        Availability</h5>
        <telerik:RadScheduler ID="RadScheduler1" runat="server" 
            DataDescriptionField="Description" DataEndField="EndDate" 
            DataKeyField="IDSubCalendar" DataSourceID="sds_Availability" 
            DataStartField="StartDate" DataSubjectField="Subject" 
            EnableDescriptionField="True" SelectedView="MonthView" Height="700px" 
            Width="650px" AllowDelete="False" AllowEdit="False" Skin="Default" 
                                        EnableCustomAttributeEditing="True" OnClientTimeSlotClick="OnClientTimeSlotClickHandler">
            <DayView UserSelectable="false" />
            <WeekView UserSelectable="false" />
            <TimeLineView UserSelectable="false" />
            <advancedform enablecustomattributeediting="True" />
    <TimelineView UserSelectable="False"></TimelineView>
      
    <WeekView UserSelectable="False"></WeekView>
      
    <DayView UserSelectable="False"></DayView>
        </telerik:RadScheduler>
                                    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="sds_SubRequests" 
                                        GridLines="None">
    <MasterTableView autogeneratecolumns="False" datasourceid="sds_SubRequests">
    <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
      
    <RowIndicatorColumn>
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
      
    <ExpandCollapseColumn>
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>
        <Columns>
            <telerik:GridBoundColumn DataField="DateSubNeeded" DataType="System.DateTime" 
                HeaderText="DateSubNeeded" SortExpression="DateSubNeeded" 
                UniqueName="DateSubNeeded">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Reason" HeaderText="Reason" 
                SortExpression="Reason" UniqueName="Reason">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Location" HeaderText="Location" 
                SortExpression="Location" UniqueName="Location">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="FullName" HeaderText="FullName" 
                ReadOnly="True" SortExpression="FullName" UniqueName="FullName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="OU" HeaderText="OU" SortExpression="OU" 
                UniqueName="OU">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Telephone1" HeaderText="Telephone1" 
                SortExpression="Telephone1" UniqueName="Telephone1">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
                                    </telerik:RadGrid>
                                    <p>
                                         </p>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
                    </td>
                </tr>
            </table>
        </div>
                <div id="footer">
      
        </div>
      
        <br />
        <telerik:RadScriptManager ID="rsm_SCS" Runat="server">
        </telerik:RadScriptManager>
        <telerik:RadFormDecorator ID="rfd_SCS" Runat="server" Skin="Default" />
                <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                    <ajaxsettings>
                        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                            <updatedcontrols>
                                <telerik:AjaxUpdatedControl ControlID="sds_SubRequests" UpdatePanelHeight="" />
                            </updatedcontrols>
                        </telerik:AjaxSetting>
                        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">   
        <updatedcontrols>   
            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />   
        </updatedcontrols>   
    </telerik:AjaxSetting>
                    </ajaxsettings>
                </telerik:RadAjaxManager>
        
    <br />
            <asp:SqlDataSource ID="sds_SCS_MenuConsole" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Human_ResourcesConnectionString %>" 
            SelectCommand="SELECT [DataFieldID], [DataFieldParentID], [DataTextField], [DataNavigateUrlField], [ImageURL] FROM [SCS_MenuConsole]">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="sds_Availability" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Human_ResourcesConnectionString %>" 
            DeleteCommand="DELETE FROM [SCS_SubCalendar] WHERE [IDSubCalendar] = @IDSubCalendar" 
            InsertCommand="INSERT INTO [SCS_SubCalendar] ([StartDate], [EndDate], [Resource], [Subject], [Description]) VALUES (@StartDate, @EndDate, @Resource, @Subject, @Description)" 
            SelectCommand="SELECT [IDSubCalendar], [StartDate], [EndDate], [Resource], [Subject], [Description] FROM [SCS_SubCalendar]" 
              
            UpdateCommand="UPDATE [SCS_SubCalendar] SET [StartDate] = @StartDate, [EndDate] = @EndDate, [Resource] = @Resource, [Subject] = @Subject, [Description] = @Description WHERE [IDSubCalendar] = @IDSubCalendar">
            <DeleteParameters>
                <asp:Parameter Name="IDSubCalendar" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="StartDate" Type="DateTime" />
                <asp:Parameter Name="EndDate" Type="DateTime" />
                <asp:Parameter Name="Resource" Type="String" />
                <asp:Parameter Name="Subject" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="StartDate" Type="DateTime" />
                <asp:Parameter Name="EndDate" Type="DateTime" />
                <asp:Parameter Name="Resource" Type="String" />
                <asp:Parameter Name="Subject" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="IDSubCalendar" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="sds_SubRequests" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Human_ResourcesConnectionString %>" 
            SelectCommand="SELECT [DateSubNeeded], [Reason], [Location], [FullName], [OU], [Telephone1] FROM [vw_SCS_SubRequests] WHERE ([DateSubNeeded] = @DateSubNeeded)">
            <SelectParameters>
                <asp:Parameter Name="clickedDateTime" Type="DateTime" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
          
        </form>
          
        </body>
    </html>

    Imports System.Data
    Imports System.Data.SqlClient
    Imports Telerik.Web.UI
    Imports System.CodeDom
    Imports System.Web
    Imports System.Web.Security
    Imports System.Web.Security.Roles
    Imports System.Web.Security.Membership
    Imports System.Security
    Imports System.Security.Principal.WindowsIdentity
    Partial Class _Default
        Inherits System.Web.UI.Page
      
        Protected Sub RadPanelBar1_DataBound1(ByVal sender As Object, ByVal e As System.EventArgs) Handles rpb_SCS.DataBound
            rpb_SCS.Items(0).Expanded = True
        End Sub
      
        Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)
            RadScheduler1.SelectedDate = DateTime.Parse(e.Argument)
            RadScheduler1.SelectedView = SchedulerViewType.MonthView
            sds_SubRequests.SelectParameters("clickedDateTime").DefaultValue = RadScheduler1.SelectedDate
            RadGrid1.MasterTableView.Rebind()
        End Sub
      
      
    End Class

  5. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 07 Dec 2010 Link to this post

    Hello Allan,

    Try attaching an event handler to the Selecting event of the SqlDataSource which the grid is bound to and in the handler assign the Value property of the parameter:

    e.Command.Parameters["clickedDateTime"].Value = RadScheduler1.SelectedDate;

    Best wishes,
    Tsvetoslav
    the Telerik team

    Browse the vast support resources we have to jumpstart 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.
  6. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 07 Dec 2010 Link to this post

    Tsvetoslav, Thank you for the reply.

    I added the suggestions to my code behind and now I receive the follwoing error:

              An SqlParameter with ParameterName 'clickedDateTime' is not contained by this SqlParameterCollection.

    Here is my changed code behind:

    Imports System.Data
    Imports System.Data.SqlClient
    Imports Telerik.Web.UI
    Imports System.CodeDom
    Imports System.Web
    Imports System.Web.Security
    Imports System.Web.Security.Roles
    Imports System.Web.Security.Membership
    Imports System.Security
    Imports System.Security.Principal.WindowsIdentity
    Partial Class _Default
        Inherits System.Web.UI.Page
      
        Protected Sub RadPanelBar1_DataBound1(ByVal sender As Object, ByVal e As System.EventArgs) Handles rpb_SCS.DataBound
            rpb_SCS.Items(0).Expanded = True
        End Sub
      
        Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)
            RadScheduler1.SelectedDate = DateTime.Parse(e.Argument)
            RadScheduler1.SelectedView = SchedulerViewType.MonthView
            sds_SubRequests.SelectParameters("clickedDateTime").DefaultValue = RadScheduler1.SelectedDate
            RadGrid1.MasterTableView.Rebind()
        End Sub
      
      
        Protected Sub sds_SubRequests_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles sds_SubRequests.Selecting
            e.Command.Parameters("clickedDateTime").Value = RadScheduler1.SelectedDate
      
        End Sub
    End Class


  7. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 08 Dec 2010 Link to this post

    Hi Allan,

    Excuse me for having left behind the @ symbol from the parameter name. The correct statement should be:
    e.Command.Parameters("@clickedDateTime").Value = RadScheduler1.SelectedDate 

    Greetings,
    Tsvetoslav
    the Telerik team
    Browse the vast support resources we have to jumpstart 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.
  8. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 08 Dec 2010 Link to this post

    Tsvetoslav, thank you again for the reply.

    I ammended the code as indicated however that also did not resolve my issue.

    I have created a bare bones example of what I am attempting. The ASPX file only has a Scheduler, Grid, Ajax Manager, Script Manager, and two SQLdatasources.

    The only thing I can think of is that I am missing a setting on the Scheduler.

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="availability_calendar.aspx.vb" Inherits="_Default" %>
    <%@ Register Assembly="Telerik.Web.UI, Version=2010.2.713.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
    <head id="Head1" runat="server">
        <title>TUSD - Substitute Calender System</title>
      
    </head>
    <body>
        <form id="form1" runat="server">
      
      
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">      
            <script type="text/javascript">
                function OnClientTimeSlotClickHandler(sender, eventArgs) {
                    if (sender.get_selectedView() == Telerik.Web.UI.SchedulerViewType.MonthView) {
                        $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest(eventArgs.get_time().format("MM/dd/yyyy"));
                    }
                }          
            </script>     
        </telerik:RadCodeBlock
      
      
      
        <br />
        <telerik:RadScheduler ID="RadScheduler1" runat="server" 
            DataDescriptionField="Description"
            DataEndField="EndDate" 
            DataKeyField="IDSubCalendar"
            DataSourceID="sds_Availability" 
            DataStartField="StartDate"
            DataSubjectField="Subject" 
            EnableDescriptionField="True"
            SelectedView="MonthView"
            Height="570px" 
            Width="650px"
            Skin="Default" 
            EnableCustomAttributeEditing="True"
            OnClientTimeSlotClick="OnClientTimeSlotClickHandler">
                <TimelineView UserSelectable="False"></TimelineView>
                <WeekView UserSelectable="False"></WeekView>
                <DayView UserSelectable="False"></DayView>
        </telerik:RadScheduler>
      
        <br />
      
        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="sds_SubRequests" GridLines="None">
            <MasterTableView autogeneratecolumns="False" datasourceid="sds_SubRequests">
            <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
            <RowIndicatorColumn>
            <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn>
            <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridBoundColumn DataField="DateSubNeeded" DataType="System.DateTime" 
                        HeaderText="DateSubNeeded" SortExpression="DateSubNeeded" 
                        UniqueName="DateSubNeeded">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Reason" HeaderText="Reason" 
                        SortExpression="Reason" UniqueName="Reason">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Location" HeaderText="Location" 
                        SortExpression="Location" UniqueName="Location">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FullName" HeaderText="FullName" 
                        ReadOnly="True" SortExpression="FullName" UniqueName="FullName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="OU" HeaderText="OU" SortExpression="OU" 
                        UniqueName="OU">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Telephone1" HeaderText="Telephone1" 
                        SortExpression="Telephone1" UniqueName="Telephone1">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
      
        <br />
        <br />
      
        <telerik:RadScriptManager ID="rsm_SCS" Runat="server">
        </telerik:RadScriptManager>
                <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                    <ajaxsettings>
                        <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                            <updatedcontrols>
                                <telerik:AjaxUpdatedControl ControlID="RadGrid1" UpdatePanelHeight="" />
                                <telerik:AjaxUpdatedControl ControlID="sds_SubRequests" UpdatePanelHeight="" />
                            </updatedcontrols>
                        </telerik:AjaxSetting>
                    </ajaxsettings>
                </telerik:RadAjaxManager>
        
        <asp:SqlDataSource ID="sds_Availability" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Human_ResourcesConnectionString %>" 
            DeleteCommand="DELETE FROM [SCS_SubCalendar] WHERE [IDSubCalendar] = @IDSubCalendar" 
            InsertCommand="INSERT INTO [SCS_SubCalendar] ([StartDate], [EndDate], [Resource], [Subject], [Description]) VALUES (@StartDate, @EndDate, @Resource, @Subject, @Description)" 
            SelectCommand="SELECT [IDSubCalendar], [StartDate], [EndDate], [Resource], [Subject], [Description] FROM [SCS_SubCalendar]" 
              
            UpdateCommand="UPDATE [SCS_SubCalendar] SET [StartDate] = @StartDate, [EndDate] = @EndDate, [Resource] = @Resource, [Subject] = @Subject, [Description] = @Description WHERE [IDSubCalendar] = @IDSubCalendar">
            <DeleteParameters>
                <asp:Parameter Name="IDSubCalendar" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="StartDate" Type="DateTime" />
                <asp:Parameter Name="EndDate" Type="DateTime" />
                <asp:Parameter Name="Resource" Type="String" />
                <asp:Parameter Name="Subject" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="StartDate" Type="DateTime" />
                <asp:Parameter Name="EndDate" Type="DateTime" />
                <asp:Parameter Name="Resource" Type="String" />
                <asp:Parameter Name="Subject" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="IDSubCalendar" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
      
        <asp:SqlDataSource ID="sds_SubRequests" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Human_ResourcesConnectionString %>" 
            SelectCommand="SELECT [DateSubNeeded], [Reason], [Location], [FullName], [OU], [Telephone1] FROM [vw_SCS_SubRequests] WHERE ([DateSubNeeded] = @clickedDateTime)">
            <SelectParameters>
                <asp:Parameter Name="clickedDateTime" Type="DateTime" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
          
        </form>
          
        </body>
      
    </html>

     

    Imports System.Data
    Imports System.Data.SqlClient
    Imports Telerik.Web.UI
    Imports System.CodeDom
    Imports System.Web
    Imports System.Web.Security
    Imports System.Web.Security.Roles
    Imports System.Web.Security.Membership
    Imports System.Security
    Imports System.Security.Principal.WindowsIdentity
    Partial Class _Default
        Inherits System.Web.UI.Page
      
      
        Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)
            RadScheduler1.SelectedDate = DateTime.Parse(e.Argument)
            RadScheduler1.SelectedView = SchedulerViewType.MonthView
            sds_SubRequests.SelectParameters("@clickedDateTime").DefaultValue = RadScheduler1.SelectedDate
            RadGrid1.MasterTableView.Rebind()
        End Sub
      
      
        Protected Sub sds_SubRequests_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles sds_SubRequests.Selecting
            e.Command.Parameters("@clickedDateTime").Value = RadScheduler1.SelectedDate
      
        End Sub
    End Class

    Thank you again for your reply.

  9. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 09 Dec 2010 Link to this post

    Allan,

    I am still unable to see the correct ajax settings described in my first post. Attached is a small sample.

    Regards,
    Tsvetoslav
    the Telerik team
    Browse the vast support resources we have to jumpstart 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.
  10. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 09 Dec 2010 Link to this post

    Tsvetoslav,

    Thank you again. I appologize to be so frustrating. However, I just can't get this worked out.

    I have now updated my code to include everything you suggested. I went so far as to copy your Ajax Manager and your Javascript and paste them in my code so I know it is exaclty the same as you suggest. I also did this for my code behind.

    Perhaps I am not converting the C# code to VB correctly but Visual Studio does not like the Page_Init code you suggest in your example. At least not for VB.  Here is the conversion:

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
            RadAjaxManager1.AjaxRequest += New RadAjaxControl.AjaxRequestDelegate(RadAjaxManager1_AjaxRequest)
            sds_SubRequests.Selecting += New SqlDataSourceSelectingEventHandler(sds_SubRequests_Selecting)
        End Sub

    The error is:

    'Public Event AjaxRequest(sender As Object, e As Telerik.Web.UI.AjaxRequestEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.


    Here again is my new complete code:

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="availability_calendar.aspx.vb" Inherits="_Default" %>
    <%@ Register Assembly="Telerik.Web.UI, Version=2010.2.713.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
    <head id="Head1" runat="server">
        <title>TUSD - Substitute Calender System</title>
      
    </head>
    <body>
        <form id="form1" runat="server">
      
      
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">      
                    <script type="text/javascript">
                        function OnClientTimeSlotClickHandler(sender, eventArgs) {
                            $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest(eventArgs.get_time().format("MM/dd/yyyy"));
                        }
            </script>
        </telerik:RadCodeBlock
      
      
        <telerik:RadScheduler ID="RadScheduler1" runat="server" 
            DataDescriptionField="Description"
            DataEndField="EndDate" 
            DataKeyField="IDSubCalendar"
            DataSourceID="sds_Availability" 
            DataStartField="StartDate"
            DataSubjectField="Subject" 
            SelectedView="MonthView"
            Height="570px" 
            Width="650px"
            OnClientTimeSlotClick="OnClientTimeSlotClickHandler">
        </telerik:RadScheduler>
      
        <br />
        <br />
      
      
        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="sds_SubRequests" GridLines="None">
            <MasterTableView autogeneratecolumns="False" datasourceid="sds_SubRequests">
            <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
            <RowIndicatorColumn>
            <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn>
            <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridBoundColumn DataField="DateSubNeeded" DataType="System.DateTime" 
                        HeaderText="DateSubNeeded" SortExpression="DateSubNeeded" 
                        UniqueName="DateSubNeeded">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Reason" HeaderText="Reason" 
                        SortExpression="Reason" UniqueName="Reason">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Location" HeaderText="Location" 
                        SortExpression="Location" UniqueName="Location">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FullName" HeaderText="FullName" 
                        ReadOnly="True" SortExpression="FullName" UniqueName="FullName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="OU" HeaderText="OU" SortExpression="OU" 
                        UniqueName="OU">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Telephone1" HeaderText="Telephone1" 
                        SortExpression="Telephone1" UniqueName="Telephone1">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
      
        <br />
        <br />
      
        <telerik:RadScriptManager ID="rsm_SCS" Runat="server">
        </telerik:RadScriptManager>
      
        <br />
        <br />
      
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        
      
      
        <asp:SqlDataSource ID="sds_Availability" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Human_ResourcesConnectionString %>" 
            DeleteCommand="DELETE FROM [SCS_SubCalendar] WHERE [IDSubCalendar] = @IDSubCalendar" 
            InsertCommand="INSERT INTO [SCS_SubCalendar] ([StartDate], [EndDate], [Resource], [Subject], [Description]) VALUES (@StartDate, @EndDate, @Resource, @Subject, @Description)" 
            SelectCommand="SELECT [IDSubCalendar], [StartDate], [EndDate], [Resource], [Subject], [Description] FROM [SCS_SubCalendar]" 
            UpdateCommand="UPDATE [SCS_SubCalendar] SET [StartDate] = @StartDate, [EndDate] = @EndDate, [Resource] = @Resource, [Subject] = @Subject, [Description] = @Description WHERE [IDSubCalendar] = @IDSubCalendar">
            <DeleteParameters>
                <asp:Parameter Name="IDSubCalendar" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="StartDate" Type="DateTime" />
                <asp:Parameter Name="EndDate" Type="DateTime" />
                <asp:Parameter Name="Resource" Type="String" />
                <asp:Parameter Name="Subject" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="StartDate" Type="DateTime" />
                <asp:Parameter Name="EndDate" Type="DateTime" />
                <asp:Parameter Name="Resource" Type="String" />
                <asp:Parameter Name="Subject" Type="String" />
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="IDSubCalendar" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
      
      
        <asp:SqlDataSource ID="sds_SubRequests" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Human_ResourcesConnectionString %>" 
            SelectCommand="SELECT [DateSubNeeded], [Reason], [Location], [FullName], [OU], [Telephone1] FROM [vw_SCS_SubRequests] WHERE ([DateSubNeeded] = @clickedDateTime)">
            <SelectParameters>
                <asp:Parameter Name="clickedDateTime" DefaultValue="12/09/2010" Type="DateTime" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
          
        </form>
          
        </body>
      
    </html>

    Imports System.Data
    Imports System.Data.SqlClient
    Imports Telerik.Web.UI
    Imports System.CodeDom
    Imports System.Web
    Imports System.Web.Security
    Imports System.Web.Security.Roles
    Imports System.Web.Security.Membership
    Imports System.Security
    Imports System.Security.Principal.WindowsIdentity
    Partial Class _Default
        Inherits System.Web.UI.Page
      
        Private explicitRebind As Boolean = False
      
      
        Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
            RadAjaxManager1.AjaxRequest += New RadAjaxControl.AjaxRequestDelegate(RadAjaxManager1_AjaxRequest)
            sds_SubRequests.Selecting += New SqlDataSourceSelectingEventHandler(sds_SubRequests_Selecting)
        End Sub
      
      
        Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)
      
            RadScheduler1.SelectedDate = DateTime.Parse(e.Argument)
            explicitRebind = True
            RadGrid1.MasterTableView.Rebind()
      
        End Sub
      
      
        Protected Sub sds_SubRequests_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles sds_SubRequests.Selecting
      
            If explicitRebind Then
                e.Command.Parameters("@clickedDateTime").Value = RadScheduler1.SelectedDate
      
            End If
        End Sub
      
      
    End Class




  11. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 14 Dec 2010 Link to this post

    Hello Allan,

    The code converter you are using is giving you the wrong statements. In VB.NET you attach event hanlders as follows:

    AddHandler YourObject.Event, AddressOf EventHandler

    Regards,
    Tsvetoslav
    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017