

function ToggleDiv(Flag) { if (Flag == "first") { document.getElementById('gridZonesLosses').style.display = 'block'; document.getElementById('chartZonesLosses').style.display = 'none'; document.getElementById('gridZonesLosses').style.width = "100%"; } else { document.getElementById('chartZonesLosses').style.display = 'block'; document.getElementById('gridZonesLosses').style.width = "17%"; document.getElementById('gridZonesLosses').style.cssFloat = "left"; document.getElementById('gridZonesLosses').style.display = 'block'; document.getElementById('chartZonesLosses').style.width = "82%"; }}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/
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" %>--%> <html xmlns="http://www.w3.org/1999/xhtml"> <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
<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.

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.
|
[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 |
| <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> |
| 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) |
| { |
| } |
| } |