Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
181 views

Hi,
I am trying to implement the Radscheduler using "External edit in raddock" as in 
http://demos.telerik.com/aspnet-ajax/scheduler/examples/raddock/defaultcs.aspx 
I am getting a javascript error as "Microsoft JScript runtime error: Unable to get value of the property 'indexOf': object is null or undefined" while clicking on a time slot and selecting 'new appointment'.
I have already put this issue in the forum before also,but couldn't get it resolved.Even though this is a duplication in the thread,thought of  starting it as a new thread as earlier thread was continuation of different thread with a different subjetct.So if  someone has faced same issue before,they  could help me out in this.

The only change I have made from the demo is that ,I have changed session datasource with sql datasource.Please find my markup for the same.
Also I have recorded a video showing the error in the link http://www.screencast.com/t/z8EbrNHnBDH  
aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FrmScheduling.aspx.cs"
    Inherits="UnicareSystemWeb.FramePages.Registration.FrmScheduling" %>
  
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%--<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>--%>
<%--<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>--%>
<%--<%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
<%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
<%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
<%@ Register TagPrefix="sds" Namespace="Telerik.Web.SessionDS" %>--%>
<head runat="server">
    <link href="../../Styles/StyleScheduler.css" rel="stylesheet" type="text/css" />
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
    <telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
        <script type="text/javascript">
  
            function openForm() {
                var dock = $find("<%= RadDock1.ClientID %>");
                // Center the RadDock on the screen
                var viewPort = $telerik.getViewPortSize();
                var xPos = Math.round((viewPort.width - parseInt(dock.get_width())) / 2);
                var yPos = Math.round((viewPort.height - parseInt(dock.get_height())) / 2);
                $telerik.setLocation(dock.get_element(), { x: xPos, y: yPos });
  
                dock.set_closed(false);
  
                var descriptionTextBox = $get('<%= DescriptionText.ClientID %>');
                descriptionTextBox.focus();
  
                Sys.Application.remove_load(openForm);
            }
  
            function hideForm() {
                var dock = $find("<%= RadDock1.ClientID %>");
                dock.set_closed(true);
  
                return true;
            }
  
            function dockMoved(sender, args) {
                //Return RadDock to his original HTML parent so it gets updated via ajax
                $get("<%= DockPanel.ClientID %>").appendChild(sender.get_element());
            }
  
        </script>
    </telerik:RadScriptBlock>
    <asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Panel runat="server" ID="DockPanel">
                <telerik:RadDock runat="server" ID="RadDock1" Width="650px" Height="530px" Closed="true"
                    Style="z-index: 2000;" Title="Edit appointment" OnClientDockPositionChanged="dockMoved">
                    <Commands>
                        <telerik:DockCloseCommand />
                    </Commands>
                    <ContentTemplate>
                        <div class="editForm">
                            <div class="header">
                                <asp:Label runat="server" ID="StatusLabel"></asp:Label>
                            </div>
                            <div class="content">
                                Description:<br />
                                <asp:TextBox runat="server" ID="DescriptionText" Width="240px"></asp:TextBox>
                                <asp:RequiredFieldValidator runat="server" ID="DescriptionTextRequiredFieldValidator"
                                    Display="Dynamic" ControlToValidate="DescriptionText" ErrorMessage="Description is required" />
                                <br />
                                <br />
                                Starts at:
                                <telerik:RadDateTimePicker ID="StartTime" runat="server" SharedCalendarID="SharedCalendar"
                                    SharedTimeViewID="SharedTimeView">
                                </telerik:RadDateTimePicker>
                                <asp:RequiredFieldValidator runat="server" ID="StartTimeRequiredFieldValidator" Display="Dynamic"
                                    ControlToValidate="StartTime" ErrorMessage="Start time is required" />
                                <br />
                                <br />
                                Ends at:
                                <telerik:RadDateTimePicker ID="EndTime" runat="server" SharedCalendarID="SharedCalendar"
                                    SharedTimeViewID="SharedTimeView">
                                </telerik:RadDateTimePicker>
                                <asp:RequiredFieldValidator runat="server" ID="EndTimeRequiredFieldValidator" Display="Dynamic"
                                    ControlToValidate="EndTime" ErrorMessage="End time is required" />
                                <br />
                                <br />
                                Assigned to:
                                <asp:DropDownList runat="server" ID="UserDropDown" DataSourceID="UsersDataSource"
                                    DataTextField="doc_name" DataValueField="doc_id">
                                </asp:DropDownList>
                                <br />
                                <br />
                                <asp:Label runat="server" Text="Reminder" ID="lblReminders"></asp:Label>
                                <telerik:RadComboBox runat="server" ID="ReminderDropDown" Width="120px">
                                    <Items>
                                        <telerik:RadComboBoxItem Text="None" Value="" />
                                        <telerik:RadComboBoxItem Text="0 minutes" Value="0" />
                                        <telerik:RadComboBoxItem Text="1 minute" Value="5" />
                                        <telerik:RadComboBoxItem Text="2 minutes" Value="10" />
                                        <telerik:RadComboBoxItem Text="3 minutes" Value="15" />
                                        <telerik:RadComboBoxItem Text="4 minutes" Value="30" />
                                        <telerik:RadComboBoxItem Text="1 hour" Value="60" />
                                        <telerik:RadComboBoxItem Text="2 hours" Value="120" />
                                        <telerik:RadComboBoxItem Text="3 hours" Value="180" />
                                        <telerik:RadComboBoxItem Text="4 hours" Value="240" />
                                        <telerik:RadComboBoxItem Text="5 hours" Value="300" />
                                        <telerik:RadComboBoxItem Text="6 hours" Value="360" />
                                        <telerik:RadComboBoxItem Text="7 hours" Value="420" />
                                        <telerik:RadComboBoxItem Text="8 hours" Value="480" />
                                        <telerik:RadComboBoxItem Text="9 hours" Value="540" />
                                        <telerik:RadComboBoxItem Text="10 hours" Value="600" />
                                        <telerik:RadComboBoxItem Text="11 hours" Value="660" />
                                        <telerik:RadComboBoxItem Text="12 hours" Value="720" />
                                        <telerik:RadComboBoxItem Text="18 hours" Value="1080" />
                                        <telerik:RadComboBoxItem Text="1 day" Value="1440" />
                                        <telerik:RadComboBoxItem Text="2 days" Value="2880" />
                                        <telerik:RadComboBoxItem Text="3 days" Value="4320" />
                                        <telerik:RadComboBoxItem Text="4 days" Value="5760" />
                                        <telerik:RadComboBoxItem Text="1 week" Value="10080" />
                                        <telerik:RadComboBoxItem Text="2 weeks" Value="20160" />
                                    </Items>
                                </telerik:RadComboBox>
                            </div>
                            <div class="footer">
                                <asp:Button runat="server" ID="SubmitButton" Text="Update" OnClick="SubmitButton_Click" />
                                <button onclick="hideForm();" type="button" style="margin-right: 20px;">
                                    Cancel</button>
                            </div>
                            <telerik:RadTimeView ID="SharedTimeView" runat="server">
                            </telerik:RadTimeView>
                            <telerik:RadCalendar ID="SharedCalendar" runat="server" EnableMonthYearFastNavigation="False"
                                EnableMultiSelect="False" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False">
                            </telerik:RadCalendar>
                            <asp:HiddenField runat="server" ID="_originalRecurrenceRule" />
                            <telerik:RadSchedulerRecurrenceEditor runat="server" ID="RadSchedulerRecurrenceEditor1" />
                        </div>
                    </ContentTemplate>
                </telerik:RadDock>
            </asp:Panel>
              <telerik:RadScheduler runat="server" ID="RadScheduler1" Width="750px" TimeZoneOffset="03:00:00"
                SelectedDate="2012-04-16" DayStartTime="08:00:00" DayEndTime="18:00:00" StartEditingInAdvancedForm="false"
                SelectedView="DayView" DataKeyField="Fld_AppId" DataSubjectField="Subject" DataStartField="Fld_AppFtime"
                DataEndField="Fld_AppTtime" DataReminderField="Reminder" DataRecurrenceField="RecurrenceRule"
                DataRecurrenceParentKeyField="RecurrenceParentID" DataSourceID="AppointmentsDataSource"
                OnFormCreating="RadScheduler1_FormCreating" Reminders-Enabled="true" OverflowBehavior="Scroll">
                <AdvancedForm Modal="true" />
          
                <ResourceTypes>
                    <%-- <telerik:ResourceType KeyField="ID" Name="Room" TextField="RoomName" ForeignKeyField="RoomID"
                        DataSourceID="RoomsDataSource" />--%>
                    <telerik:ResourceType KeyField="doc_id" Name="Doctor" TextField="doc_name" ForeignKeyField="MdiSft_Emp_ID"
                        DataSourceID="UsersDataSource" />
                </ResourceTypes>
                <TimeSlotContextMenuSettings EnableDefault="true" />
                <AppointmentContextMenuSettings EnableDefault="true" />
            </telerik:RadScheduler>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:SqlDataSource ID="UsersDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:UCSystemConnection %>"
        SelectCommand="SELECT * FROM [doctor_master]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="AppointmentsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:UCSystemConnection %>"         
        SelectCommand="SELECT * FROM [Tbl_FixSchedule]" >
    </asp:SqlDataSource>    
    <%--<sds:sessiondatasource id="AppointmentsDataSource" runat="server" primarykeyfields="ID"
        connectionstring="<%$ ConnectionStrings:TelerikConnectionString %>" selectcommand="SELECT * FROM [Appointments]"
        insertcommand="INSERT INTO [Appointments] ([Subject], [Start], [End], [UserID], [RoomID], [RecurrenceRule], [RecurrenceParentID], [Annotations], [Description], [Reminder], [LastModified]) VALUES (@Subject, @Start, @End, @UserID, @RoomID, @RecurrenceRule, @RecurrenceParentID, @Annotations, @Description, @Reminder, @LastModified)"
        updatecommand="UPDATE [Appointments] SET [Subject] = @Subject, [Start] = @Start, [End] = @End, [UserID] = @UserID, [RoomID] = @RoomID, [RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID, [Annotations] = @Annotations, [Description] = @Description, [Reminder] = @Reminder, [LastModified] = @LastModified WHERE [ID] = @ID"
        deletecommand="DELETE FROM [Appointments] WHERE [ID] = @ID" clearsessiononinitialload="True"
        sessionkey="System.Web.UI.Page_AppointmentsDataSource">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Subject" Type="String" />
            <asp:Parameter Name="Start" Type="DateTime" />
            <asp:Parameter Name="End" Type="DateTime" />
            <asp:Parameter Name="UserID" Type="Int32" />
            <asp:Parameter Name="RoomID" Type="Int32" />
            <asp:Parameter Name="RecurrenceRule" Type="String" />
            <asp:Parameter Name="RecurrenceParentID" Type="Int32" />
            <asp:Parameter Name="Annotations" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="Reminder" Type="String" />
            <asp:Parameter Name="LastModified" Type="String" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Subject" Type="String" />
            <asp:Parameter Name="Start" Type="DateTime" />
            <asp:Parameter Name="End" Type="DateTime" />
            <asp:Parameter Name="UserID" Type="Int32" />
            <asp:Parameter Name="RoomID" Type="Int32" />
            <asp:Parameter Name="RecurrenceRule" Type="String" />
            <asp:Parameter Name="RecurrenceParentID" Type="Int32" />
            <asp:Parameter Name="Annotations" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="Reminder" Type="String" />
            <asp:Parameter Name="LastModified" Type="String" />
        </InsertParameters>
    </sds:sessiondatasource>
    <sds:sessiondatasource id="RoomsDataSource" runat="server" displaywarning="false"
        providername="System.Data.SqlClient" connectionstring="<%$ ConnectionStrings:TelerikConnectionString %>"
        selectcommand="SELECT * FROM [Rooms]">
    </sds:sessiondatasource>
    <sds:sessiondatasource id="UsersDataSource" runat="server" displaywarning="false"
        providername="System.Data.SqlClient" connectionstring="<%$ ConnectionStrings:TelerikConnectionString %>"
        selectcommand="SELECT * FROM [Users]">
    </sds:sessiondatasource>--%>
    </form>
</body>
</html>

aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using UnicareSystemDO.Registration;
using UnicareSystemDOService.Registration;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.Collections;
using System.Drawing;
  
namespace UnicareSystemWeb.FramePages.Registration
{
    public partial class FrmScheduling : System.Web.UI.Page
    {
        //private ScheduleService _scheduleservice = null;
        bool CreatingExceptionAppointment
        {
            get { return (bool)ViewState["CreatingExceptionAppointment"]; }
            set { ViewState["CreatingExceptionAppointment"] = value; }
        }
  
        Appointment EditedAppointment
        {
            get
            {
                return (EditedAppointmentID != null) ? RadScheduler1.Appointments.FindByID(EditedAppointmentID) : null;
            }
            set
            {
                EditedAppointmentID = value.ID;
                EditedAppointmentParentID = value.RecurrenceParentID;
            }
        }
  
        Appointment EditedAppointmentParent
        {
            get
            {
                return (EditedAppointmentParentID != null) ? RadScheduler1.Appointments.FindByID(EditedAppointmentParentID) : null;
            }
        }
  
        private object EditedAppointmentID
        {
            get { return ViewState["EditedAppointmentID"]; }
            set { ViewState["EditedAppointmentID"] = value; }
        }
  
        private object EditedAppointmentParentID
        {
            get { return ViewState["EditedAppointmentParentID"]; }
            set { ViewState["EditedAppointmentParentID"] = value; }
        }
  
        protected void RadScheduler1_FormCreating(object sender, SchedulerFormCreatingEventArgs e)
        {
            RadSchedulerRecurrenceEditor1.ResetLayout();
  
            if (e.Mode == SchedulerFormMode.Insert || e.Mode == SchedulerFormMode.Edit)
            {
                EditedAppointment = e.Appointment;
                e.Cancel = true;
            }
  
            var appointmentToEdit = RadScheduler1.PrepareToEdit(e.Appointment, RadScheduler1.EditingRecurringSeries);
  
            //if (!ClientScript.IsStartupScriptRegistered("formScript"))
            //{
            //    ClientScript.RegisterStartupScript(this.GetType(), "formScript", "openForm();", true);
            //}
            //ScriptManager.RegisterStartupScript(Page, GetType(), "formScript", "openForm();", true);
            ScriptManager.RegisterStartupScript(Page, GetType(), "formScript", "Sys.Application.add_load(openForm);", true);
  
            PopulateEditForm(appointmentToEdit);
        }
  
        private bool IsAllDayAppointment(Appointment appointment)
        {
            DateTime displayStart = RadScheduler1.UtcToDisplay(appointment.Start);
            DateTime displayEnd = RadScheduler1.UtcToDisplay(appointment.End);
            return displayStart.CompareTo(displayStart.Date) == 0 && displayEnd.CompareTo(displayEnd.Date) == 0 && displayStart.CompareTo(displayEnd) != 0;
        }
  
        private DateTime Start
        {
            get
            {
                DateTime result = StartTime.SelectedDate.Value.Date;
  
                TimeSpan time = StartTime.SelectedDate.Value.TimeOfDay;
                result = result.Add(time);
  
                return RadScheduler1.DisplayToUtc(result);
            }
        }
  
        private DateTime End
        {
            get
            {
                DateTime result = EndTime.SelectedDate.Value.Date;
  
                TimeSpan time = EndTime.SelectedDate.Value.TimeOfDay;
                result = result.Add(time);
  
                return RadScheduler1.DisplayToUtc(result);
            }
        }
  
        private string RecurrenceRuleText
        {
            get
            {
                if (RadScheduler1.RecurrenceSupport)
                {
                    RadSchedulerRecurrenceEditor1.StartDate = Start;
                    RadSchedulerRecurrenceEditor1.EndDate = End;
  
                    RecurrenceRule rrule = RadSchedulerRecurrenceEditor1.RecurrenceRule;
  
                    if (rrule == null)
                    {
                        return string.Empty;
                    }
  
                    RecurrenceRule originalRule;
                    if (RecurrenceRule.TryParse(_originalRecurrenceRule.Value, out originalRule))
                    {
                        rrule.Exceptions = originalRule.Exceptions;
                    }
  
                    if (rrule.Range.RecursUntil != DateTime.MaxValue)
                    {
                        rrule.Range.RecursUntil = RadScheduler1.DisplayToUtc(rrule.Range.RecursUntil);
                    }
  
                    return rrule.ToString();
                }
  
                return string.Empty;
            }
            set
            {
                RecurrenceRule rrule = null;
  
                RecurrenceRule.TryParse(value, out rrule);
  
                if (rrule != null)
                {
                    if (rrule.Range.RecursUntil != DateTime.MaxValue)
                    {
                        DateTime recursUntil = RadScheduler1.UtcToDisplay(rrule.Range.RecursUntil);
  
                        if (!IsAllDayAppointment(EditedAppointment))
                        {
                            recursUntil = recursUntil.AddDays(-1);
                        }
  
                        rrule.Range.RecursUntil = recursUntil;
                    }
                }
                RadSchedulerRecurrenceEditor1.RecurrenceRuleText = (rrule != null) ? rrule.ToString() : value;
  
                _originalRecurrenceRule.Value = value;
            }
        }
  
        private void PopulateEditForm(Appointment editedAppointment)
        {
            Appointment appointmentToEdit = RadScheduler1.PrepareToEdit(editedAppointment, RadScheduler1.EditingRecurringSeries);
            DescriptionText.Text = appointmentToEdit.Subject;
  
            StartTime.SelectedDate = RadScheduler1.UtcToDisplay(appointmentToEdit.Start);
            EndTime.SelectedDate = RadScheduler1.UtcToDisplay(appointmentToEdit.End);
  
            if ((appointmentToEdit.Reminders.Count == 0) || (ReminderDropDown.SelectedValue == ""))
            {
                ReminderDropDown.SelectedValue = "";
            }
            else
            {
                ReminderDropDown.SelectedValue = appointmentToEdit.Reminders[0].Trigger.TotalMinutes.ToString();
            }
  
            Resource user = appointmentToEdit.Resources.GetResourceByType("Doctor");
            if (user != null)
            {
                UserDropDown.SelectedValue = user.Key.ToString();
            }
  
            RadSchedulerRecurrenceEditor1.StartDate = appointmentToEdit.Start;
            RadSchedulerRecurrenceEditor1.EndDate = appointmentToEdit.End;
  
            RecurrenceRuleText = appointmentToEdit.RecurrenceRule;
        }
  
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            if (EditedAppointment == null)
            {
  
                Appointment aptToInsert = PopulateBasicAppointmentPropertiesFromForm();
  
                RadScheduler1.InsertAppointment(aptToInsert);
  
                // Insert Appointment
                //Appointment aptToInsert = PopulateBasicAppointmentPropertiesFromForm();
                //clsSchedule schedule = new clsSchedule();
                //schedule.Subject = DescriptionText.Text;
                //Resource user = new Resource("Doctor", int.Parse(UserDropDown.SelectedValue), UserDropDown.SelectedItem.Text);
                //schedule.Fld_AppFtime = RadScheduler1.DisplayToUtc(StartTime.SelectedDate.Value);
                //schedule.Fld_AppTtime = RadScheduler1.DisplayToUtc(EndTime.SelectedDate.Value);
                //schedule.Reminder = ReminderDropDown.SelectedValue;
                //schedule.RecurrenceRule = RecurrenceRuleText;
                //_scheduleservice = new ScheduleService();
                //string statusI = _scheduleservice.SaveSchdule(schedule);
  
            }
            else
            {
                if (!RadScheduler1.EditingRecurringSeries && (EditedAppointmentParent != null || EditedAppointment.RecurrenceState == RecurrenceState.Master))
                {
                    // Create Exception Appointment
                    var aptOccurence = EditedAppointment;
                    var aptException = PopulateBasicAppointmentPropertiesFromForm(
                                        RadScheduler1.PrepareToEdit(aptOccurence, RadScheduler1.EditingRecurringSeries)
                    );
  
                    RadScheduler1.UpdateAppointment(aptException);
                }
                else
                {
                    // Update Appointment
                    Appointment aptOriginal = EditedAppointment;
  
                    if (RadScheduler1.EditingRecurringSeries && (aptOriginal.RecurrenceState == RecurrenceState.Occurrence || aptOriginal.RecurrenceState == RecurrenceState.Exception))
                        aptOriginal = EditedAppointmentParent;
  
                    Appointment aptToUpdate = PopulateBasicAppointmentPropertiesFromForm(aptOriginal.Clone());
  
                    RadScheduler1.UpdateAppointment(aptToUpdate, aptOriginal);
                }
            }
  
            EditedAppointmentID = "";
            EditedAppointmentParentID = "";
  
            RadDock1.Closed = true;
        }
  
        private Appointment PopulateBasicAppointmentPropertiesFromForm()
        {
            return PopulateBasicAppointmentPropertiesFromForm(null);
        }
  
        private Appointment PopulateBasicAppointmentPropertiesFromForm(Appointment apt)
        {
            if (apt == null)
                apt = new Appointment();
  
            Resource user = new Resource("Doctor", int.Parse(UserDropDown.SelectedValue), UserDropDown.SelectedItem.Text);
            DateTime start = RadScheduler1.DisplayToUtc(StartTime.SelectedDate.Value);
            DateTime end = RadScheduler1.DisplayToUtc(EndTime.SelectedDate.Value);
            string reminder = ReminderDropDown.SelectedValue;
  
            apt.Subject = DescriptionText.Text;
            apt.Start = start;
            apt.End = end;
  
            apt.RecurrenceRule = RecurrenceRuleText;
  
            if (!String.IsNullOrEmpty(reminder))
            {
                apt.Reminders.Add(new Reminder(int.Parse(reminder)));
            }
  
            Resource existingUser = apt.Resources.GetResourceByType("Doctor");
            if (existingUser != null)
            {
                apt.Resources.Remove(existingUser);
            }
            apt.Resources.Add(user);
  
            return apt;
        }
    }
}

Thanks,
Soumya

Soumya
Top achievements
Rank 1
 answered on 23 Aug 2012
1 answer
125 views
Hi,

I have a rad grid with a template column that contains image:

<telerik:GridTemplateColumn

HeaderText="Status" HeaderStyle-Width="50px" ItemStyle-Width="16px"

UniqueName="SensorConnectionStatus" AllowFiltering="false">

<ItemTemplate>

<asp:Image ID="StatusImage" runat="server" Width="16px" Height="16px"/>

</ItemTemplate>

</telerik:GridTemplateColumn>


In the databound column I have the following code:

 

        if (e.Item is GridDataItem)
        {
            GridDataItem myGridItem = (GridDataItem)e.Item;
            bool IsOnlineSensor = IsOnline(DataBinder.Eval(e.Item.DataItem, "SensorConnectionStatusCode"));

            Image image = (Image)myGridItem["SensorConnectionStatus"].FindControl("StatusImage");

            if (IsOnlineSensor)
            {
                image.ImageUrl = "~/Images/Design/a.png";
                image.ToolTip = "Online";
            }
            else
            {
                image.ImageUrl = "~/Images/Design/b.png";
                image.ToolTip = "Offline";
            }
        }


I have a refresh button that calls the client side function that should rebind the grid:

function RebindCxSensorsGrid() {

 

var masterTable = $find("<%= gvSensors.ClientID %>").get_masterTableView();

masterTable.rebind();

}

The problem is that I have an online sensor with the image a.png, but after I press the refresh button it should change to offline and display b.png in the grid.
I put a breakpoint and I see that the data is correct, but the image didn't change...

Do you have any idea what am I doing wrong?
If I load the page again, the icon changes.

Thanks.

 

 

Eyup
Telerik team
 answered on 23 Aug 2012
3 answers
79 views
Consider the example on http://demos.telerik.com/aspnet-ajax/rotator/examples/default/defaultcs.aspx and change the RotatorType to Buttons and the Width to 1000px.
Is there any solution how to have a smoother moving when clicking on the rotator buttons?

When WrapFrames is disabled, the rotation seems to look good, but we indeed need the WrapFrames functionality set to true.

Thanks in advance
Slav
Telerik team
 answered on 23 Aug 2012
13 answers
611 views
Hello,

I am really struggling on this.  A quick solution would be great before I go crazy, thanks.

I have a problem trying to get images working in RadGrid.  I am using an existing SQL table (SQL 2005 Developer) which has product images stored as column type image.  These display fine in Winforms radgrid controls.  Under asp.net though I keep getting errors about invalid parameters.

The exception is shown

Server Error in '/GP_V1_00' Application.

Parameter is not valid.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Parameter is not valid.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: Parameter is not valid.]
   System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData) +1062843
   System.Drawing.Image.FromStream(Stream stream) +8
   Telerik.Web.UI.ImageFilterHelper.CreateImgFromBytes(Byte[] image) +99

[ArgumentException: The provided binary data may not be valid image or may contains unknown header]
   Telerik.Web.UI.ImageFilterHelper.CreateImgFromBytes(Byte[] image) +173
   Telerik.Web.UI.BinaryImageTransformationFilter.ProcessImageInternal(Byte[] image) +53
   Telerik.Web.UI.BinaryImageTransformationFilter.ProcessImage(Byte[] image) +54
   Telerik.Web.UI.BinaryImageFilterProcessor.ProcessFilters(Byte[] imageData) +188
   Telerik.Web.UI.RadBinaryImage.ProcessImageData() +124
   Telerik.Web.UI.RadBinaryImage.OnPreRender(EventArgs e) +41
   System.Web.UI.Control.PreRenderRecursiveInternal() +80
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842


Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082



My code is shown here.

 <telerik:RadGrid ID="RadGridImages" runat="server" DataSourceID="SqlDataSourceImages" 
        GridLines="None" AutoGenerateColumns="False"
        <MasterTableView DataKeyNames="Id" DataSourceID="SqlDataSourceImages"
            <Columns> 
                <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="Id" ReadOnly="True" 
                    SortExpression="Id" UniqueName="Id"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Product_Id" DataType="System.Int32" HeaderText="Product_Id" 
                    SortExpression="Product_Id" UniqueName="Product_Id"
                </telerik:GridBoundColumn> 
                <telerik:GridBinaryImageColumn DataField="image" HeaderText="Image" UniqueName="ProdImage" 
                    ImageAlign="Middle" ImageHeight="150px" ImageWidth="200px" ResizeMode="Fit" DataAlternateTextField="Id" 
                    DataAlternateTextFormatString="Image of {0}"
                </telerik:GridBinaryImageColumn> 
            </Columns> 
        </MasterTableView> 
    </telerik:RadGrid> 

Code behind code for handling images or adding them...

   protected void ButtonAddImage_Click(object sender, EventArgs e) 
    { 
        if (RadGridProducts.SelectedItems.Count < 1 || (string.IsNullOrEmpty(FileUploadImage.FileName))) 
            return
 
        string strId = ((GridDataItem)RadGridProducts.SelectedItems[0]).GetDataKeyValue("Id").ToString(); 
 
        // Create the image 
        byte[] imageData = this.FileUploadImage.FileBytes; 
        SaveImage(strId, imageData); 
    } 
 
    private void SaveImage(string strImageId, byte[] imageData) 
    { 
        try 
        { 
            this.SqlDataSourceImages.InsertCommand = "INSERT INTO Product_Image (Product_Id, Image) " + 
                "VALUES ('" + strImageId + "','" + imageData + "')"
            try 
            { 
                this.SqlDataSourceImages.Insert(); 
            } 
            catch (SqlException sqlex) 
            { 
                this.LabelStatus.Text = "An exception stopped the transaction being created\r\n" + sqlex.ToString(); 
            } 
 
        } 
        catch (Exception ex) 
        { 
        } 
    }    
Martin
Telerik team
 answered on 23 Aug 2012
10 answers
191 views
Hi there,
I want to use radrotator with pagination which means I have to rotate three images automatically, on every image rotation the pagination with numbers 1,2,3 have to selected for respective images....which  it is possible in radrotator?.

Thanks in advance,
Regards,
suresh.
Slav
Telerik team
 answered on 23 Aug 2012
2 answers
85 views
I have placed a delete button in the ItemTemplate section and the AlternatingItemTemplate area.  When I try and click on the button, I get the following message

You have specified that your delete command compares all values on SqlDataSource 'dsLTDist0', but the dictionary passed in for values is empty.  Pass in a valid dictionary for delete or change your mode to OverwriteChanges



I have an update button in the same line and it seems to work correctly.  here is my datasource code....

<asp:SqlDataSource ID="dsLTDist0" runat="server"
        ConflictDetection="CompareAllValues"
        ConnectionString="<%$ ConnectionStrings:Tech-InnovationsConnectionString %>"
        DeleteCommand="DELETE FROM [Appointments] WHERE [ID] = @original_ID"
        InsertCommand="INSERT INTO [Appointments] ([Subject], [Unit], [Area], [Vehicle], [Status], [Hours], [Comments],[Start],[End],[District]) VALUES (@Subject, @Unit, @Area, @Vehicle, @Status, @Hours, @Comments,@Start,@End,@District)"
        OldValuesParameterFormatString="original_{0}"
        SelectCommand="SELECT [ID], [Subject], [Unit], [Area], [Vehicle], [Status], [Hours], [Comments] FROM [Appointments]"
         
         
         
        UpdateCommand="UPDATE [Appointments] SET [Subject] = @Subject, [Unit] = @Unit, [Area] = @Area, [Vehicle] = @Vehicle, [Status] = @Status, [Hours] = @Hours, [Comments] = @Comments WHERE [ID] = @original_ID AND [Subject] = @original_Subject AND (([Unit] = @original_Unit) OR ([Unit] IS NULL AND @original_Unit IS NULL)) AND (([Area] = @original_Area) OR ([Area] IS NULL AND @original_Area IS NULL)) AND (([Vehicle] = @original_Vehicle) OR ([Vehicle] IS NULL AND @original_Vehicle IS NULL)) AND (([Status] = @original_Status) OR ([Status] IS NULL AND @original_Status IS NULL)) AND (([Hours] = @original_Hours) OR ([Hours] IS NULL AND @original_Hours IS NULL)) AND (([Comments] = @original_Comments) OR ([Comments] IS NULL AND @original_Comments IS NULL))">
        <DeleteParameters>
            <asp:Parameter Name="original_ID" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Subject" Type="String" />
            <asp:Parameter Name="Unit" Type="String" />
            <asp:Parameter Name="Area" Type="String" />
            <asp:Parameter Name="Vehicle" Type="String" />
            <asp:Parameter Name="Status" Type="String" />
            <asp:Parameter Name="Hours" Type="String" />
            <asp:Parameter Name="Comments" Type="String" />
            <asp:Parameter Name="Start" Type="datetime" />
            <asp:Parameter Name="End" Type="datetime" />
            <asp:Parameter Name="District" Type="int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Subject" Type="String" />
            <asp:Parameter Name="Unit" Type="String" />
            <asp:Parameter Name="Area" Type="String" />
            <asp:Parameter Name="Vehicle" Type="String" />
            <asp:Parameter Name="Status" Type="String" />
            <asp:Parameter Name="Hours" Type="String" />
            <asp:Parameter Name="Comments" Type="String" />
            <asp:Parameter Name="original_ID" Type="Int32" />
            <asp:Parameter Name="original_Subject" Type="String" />
            <asp:Parameter Name="original_Unit" Type="String" />
            <asp:Parameter Name="original_Area" Type="String" />
            <asp:Parameter Name="original_Vehicle" Type="String" />
            <asp:Parameter Name="original_Status" Type="String" />
            <asp:Parameter Name="original_Hours" Type="String" />
            <asp:Parameter Name="original_Comments" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>

and here is my ItemTemplate

<ItemTemplate>
    <tr class="rlvI">
        <td>
            <asp:Button ID="EditButton" runat="server" CausesValidation="False"
                CommandName="Edit" CssClass="rlvBEdit" Text=" " ToolTip="Edit" />
        </td>
        <td>
            <asp:Label ID="SubjectLabel" runat="server" width ="170" Text='<%# Eval("Subject") %>' />
        </td>
        <td>
            <asp:Label ID="UnitLabel" runat="server"  width ="70" Text='<%# Eval("Unit") %>' />
        </td>
        <td>
            <asp:Label ID="AreaLabel" runat="server"  width ="70" Text='<%# Eval("Area") %>' />
        </td>
        <td>
            <asp:Label ID="VehicleLabel" runat="server"  width ="70" Text='<%# Eval("Vehicle") %>' />
        </td>
        <td>
            <asp:Label ID="HoursLabel" runat="server"  width ="80" Text='<%# Eval("Hours") %>' />
        </td>
        <td>
            <asp:Label ID="StatusLabel" runat="server"  width ="100" Text='<%# Eval("Status") %>' />
        </td>
        <td>
            <asp:Label ID="CommentsLabel" runat="server"  width ="200" Text='<%# Eval("Comments") %>' />
        </td>
        <td>
            <asp:Button ID="btnDel" runat="server" CausesValidation="False"
                CommandName="Delete" CssClass="rlvBDel" Text=" " ToolTip="Delete this Record" />
        </td>
 
    </tr>
</ItemTemplate>

Any ideas or Suggestions?
Zuhair
Top achievements
Rank 1
 answered on 23 Aug 2012
1 answer
78 views
Hello

I wonder if there is some way to bypass the validation filter a column of type GridDateTimeColumn therefore need to do a custom filter on it, where the User could fill the query with special characters that assist in filtering.
For example
! 08/20/2012 Different 08/20/2012
> 08/20/2012 Greater than 08/20/2012
<08/20/2012 Smaller than 08/20/2012
and besides others.


Maybe it is possible to disable these validations further naum found no way. If you can help me thank.


Fernando
Eyup
Telerik team
 answered on 23 Aug 2012
1 answer
181 views
Hi,

I am using the Vista skin for the framework to our radWindows. However my boss doesn't like the fact that you can see through the framwork of the window to the page beneath it in the z-order. I have tried overriding the css in my own file but for some reason the opacity values have been set to !important in the embedded versions css (the one that comes from WebResourse.axd) and this always seems to take priority. So I thought I would get round this by using the online sylebuilder, grab a copy of the Vista skin call it VistaSolid, Edit the opacity values for the Window.VistaSolid.css, attach the css file to calling page and set the EnableEmbbededSkins to false for the RadWindowManager. This should have resulted in the opacity being no longer see through, however it doesn't. although the new custom skin is being used and many of the attributes are collected from there the opacity values are still coming from WebResource.axd, which they shouldn't be.

So how can I set the opacity of the skin to be 100%, and why does the opacity values of the embedded skin need to be set to !important so that they cannot be overridden, surely this is a bug isn't it?

Stuart

<link rel="Stylesheet" type="text/css" href="Styles/Skins/VistaSolid/Window.VistaSolid.css" />
<telerik:RadWindowManager ID="RadWindowManager1" Skin="VistaSolid" VisibleStatusbar="false" EnableEmbeddedSkins="false"
            Behaviors="Close, Move, Resize" runat="server" OnClientPageLoad="SetWindowManagerSize" OnClientDragStart="WindowDragStart">
            <Windows>
                <telerik:RadWindow ID="PartsListWindow" runat="server" Behaviors="Close, Move, Resize" EnableEmbeddedSkins="false"
                    NavigateUrl="../Editor.aspx" Skin="VistaSolid" Height="275px" Width="350px" ShowContentDuringLoad="false" style="z-index:5001; overflow:hidden;" >
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
Marin Bratanov
Telerik team
 answered on 23 Aug 2012
1 answer
77 views
Hello,

I think I already know the answer to this but wanted to post just in case.  I have implemented an ActiveX which scans documents and uploads them to my website.  The problem is, the upload is really hammering the system.  I was wondering if RadUpload - or another Telerik control - could possibly help out.  I am converting the image to a base64 and uploading.  But was wondering if I could somehow take the file created and use RadUpload to get the file directly to the server?  I would want to do this without user intervention, which I am guessing is not possible since RadUpload seems to be for that purpose only.  But I wanted to check anyways.  Or if there is another Telerik control that might help with the scenario I'm appreciate the input.

Thanks!
Richard
Dimitar Terziev
Telerik team
 answered on 23 Aug 2012
2 answers
684 views
Hi
I am fairly new to programming and I am using telerik radgrid to display a list of quotes for a sales application on a quote.aspx page. I have created a Hyperlink column that will redirect a user to a editquote.aspx page which will allow the user to edit specific details(product description,supplier...) of the particular quote they have chosen. The problem I am having is getting to display the chosen quote details on the editquote.aspx page in a radgrid in which they can use inline editing etc. Is there any help that I can get from the support team or anyone else on how to do this?
Louven
Top achievements
Rank 1
 answered on 23 Aug 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?