I have a page I am working on which fully functions using GridBinaryImageColumn inside a RadGrid except for one thing...I have multiple GridBinaryImageColumns, 3 actually. When I develop a page using only 1 GridBinaryImageColumn in the grid, everything is wonderful. As soon as I create a page that has 2 or even 3 GridBinaryImageColumns in the grid, I run into woerd behaviors. The behaviors are:
For the 1 GridBinaryImageColumn in the RadGrid:
- Everything works as expected.
For the 2 GridBinaryImageColumns in the RadGrid:
- Select a file for GridBinaryImageColumn 1, do not select a file for GridBinaryImageColumn 2, and the result = no uploaded files.
- Select a file for GridBinaryImageColumn 1, select a file for GridBinaryImageColumn 2, and the result = both files get uploaded.
- Do not select a file for GridBinaryImageColumn 1, select a file for GridBinaryImageColumn 2, and the result = the 2nd file is uploaded.
My Thoughts...it seems to me, GridBinaryImageColumn 2 must have a file selected in order for GridBinaryImageColumn 1 to upload successful???
For the 3 GridBinaryImageColumns in the RadGrid:
- Select a file for GridBinaryImageColumn 1, do not select a file for GridBinaryImageColumn 2, do not select a file for GridBinaryImageColumn 3, and the result = no uploaded files.
- Select a file for GridBinaryImageColumn 1, select a file for GridBinaryImageColumn 2, do not select a file for GridBinaryImageColumn 3, and the result = no uploaded files.
- Select a file for GridBinaryImageColumn 1, select a file for GridBinaryImageColumn 2, select a file for GridBinaryImageColumn 3, and the result = all files get uploaded.
- Do not select a file for GridBinaryImageColumn 1, select a file for GridBinaryImageColumn 2, do not select a file for GridBinaryImageColumn 3, and the result = no uploaded files.
- Do not select a file for GridBinaryImageColumn 1, select a file for GridBinaryImageColumn 2, select a file for GridBinaryImageColumn 3, and the result = Both files get uploaded.
- Do not select a file for GridBinaryImageColumn 1, Do not select a file for GridBinaryImageColumn 2, select a file for GridBinaryImageColumn 3, and the result = The file gets uploaded.
My Thoughts...it seems to me, GridBinaryImageColumn 3 must have a file selected in order for GridBinaryImageColumn 1 and 2 to upload successful???
I was hoping someone else has run into this and help me figure out how to remedy it. Telerik can you respond informing us if this is possible to overcome? Am I missing something? Here is my code:
ASPX Page:
CS Code Behind Page:
Let me know if what I have provided to help people understand this problem is not sufficiant.
- Randy Bigbie
For the 1 GridBinaryImageColumn in the RadGrid:
- Everything works as expected.
For the 2 GridBinaryImageColumns in the RadGrid:
- Select a file for GridBinaryImageColumn 1, do not select a file for GridBinaryImageColumn 2, and the result = no uploaded files.
- Select a file for GridBinaryImageColumn 1, select a file for GridBinaryImageColumn 2, and the result = both files get uploaded.
- Do not select a file for GridBinaryImageColumn 1, select a file for GridBinaryImageColumn 2, and the result = the 2nd file is uploaded.
My Thoughts...it seems to me, GridBinaryImageColumn 2 must have a file selected in order for GridBinaryImageColumn 1 to upload successful???
For the 3 GridBinaryImageColumns in the RadGrid:
- Select a file for GridBinaryImageColumn 1, do not select a file for GridBinaryImageColumn 2, do not select a file for GridBinaryImageColumn 3, and the result = no uploaded files.
- Select a file for GridBinaryImageColumn 1, select a file for GridBinaryImageColumn 2, do not select a file for GridBinaryImageColumn 3, and the result = no uploaded files.
- Select a file for GridBinaryImageColumn 1, select a file for GridBinaryImageColumn 2, select a file for GridBinaryImageColumn 3, and the result = all files get uploaded.
- Do not select a file for GridBinaryImageColumn 1, select a file for GridBinaryImageColumn 2, do not select a file for GridBinaryImageColumn 3, and the result = no uploaded files.
- Do not select a file for GridBinaryImageColumn 1, select a file for GridBinaryImageColumn 2, select a file for GridBinaryImageColumn 3, and the result = Both files get uploaded.
- Do not select a file for GridBinaryImageColumn 1, Do not select a file for GridBinaryImageColumn 2, select a file for GridBinaryImageColumn 3, and the result = The file gets uploaded.
My Thoughts...it seems to me, GridBinaryImageColumn 3 must have a file selected in order for GridBinaryImageColumn 1 and 2 to upload successful???
I was hoping someone else has run into this and help me figure out how to remedy it. Telerik can you respond informing us if this is possible to overcome? Am I missing something? Here is my code:
ASPX Page:
| <%@ Page Title="" Language="C#" ValidateRequest="false" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeBehind="HospitalList.aspx.cs" Inherits="Page_HospitalList" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <asp:Content ID="Content1" ContentPlaceHolderID="cphHead" runat="server"> |
| <style type="text/css"> |
| .GridEditImageButton |
| { |
| cursor: hand; |
| } |
| .GridDeleteImageButton |
| { |
| cursor: hand; |
| } |
| .EditFormHeader td |
| { |
| font-size: 14px; |
| padding: 4px !important; |
| color: #808080; |
| font-weight: bolder; |
| } |
| </style> |
| </asp:Content> |
| <asp:Content ID="Content2" ContentPlaceHolderID="cphContent" runat="server"> |
| <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
| <script type="text/javascript"> |
| function rgrdHospitalList_RowDblClick(sender, eventArgs) |
| { |
| sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical()); |
| } |
| function rgrdHospitalList_RowDropping(sender, args) { |
| if (confirm("Are you sure you want to change the order sequence for this item?") == true) { |
| return true; |
| } |
| else { |
| args.set_cancel(true); |
| return false; |
| } |
| } |
| // <![CDATA[ |
| //On insert and update buttons click temporarily disables ajax to perform upload actions |
| function conditionalPostback(sender, eventArgs) { |
| var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig"); |
| if (eventArgs.get_eventTarget().match(theRegexp)) { |
| var upload = $find(window['UploadId']); |
| //AJAX is disabled only if file is selected for upload |
| if (upload.getFileInputs()[0].value != "") { |
| eventArgs.set_enableAjax(false); |
| } |
| } |
| } |
| function validateTreeImageUpload(source, e) { |
| // e.IsValid = false; |
| // var upload = $find(source.parentNode.getElementsByTagName('div')[0].id); |
| // var inputs = upload.getFileInputs(); |
| // for (var i = 0; i < inputs.length; i++) { |
| // //check for empty string or invalid extension |
| // if (inputs[i].value != "" && upload.isExtensionValid(inputs[i].value)) { |
| // e.IsValid = true; |
| // break; |
| // } |
| // } |
| } |
| function validateTreeExpandedImageUpload(source, e) { |
| // e.IsValid = false; |
| // var upload = $find(source.parentNode.getElementsByTagName('div')[0].id); |
| // var inputs = upload.getFileInputs(); |
| // for (var i = 0; i < inputs.length; i++) { |
| // //check for empty string or invalid extension |
| // if (inputs[i].value != "" && upload.isExtensionValid(inputs[i].value)) { |
| // e.IsValid = true; |
| // break; |
| // } |
| // } |
| } |
| function validateIcon32x32ImageUpload(source, e) { |
| // e.IsValid = false; |
| // var upload = $find(source.parentNode.getElementsByTagName('div')[0].id); |
| // var inputs = upload.getFileInputs(); |
| // for (var i = 0; i < inputs.length; i++) { |
| // //check for empty string or invalid extension |
| // if (inputs[i].value != "" && upload.isExtensionValid(inputs[i].value)) { |
| // e.IsValid = true; |
| // break; |
| // } |
| // } |
| } |
| // ]]> |
| </script> |
| </telerik:RadCodeBlock> |
| <telerik:RadAjaxLoadingPanel ID="rajaxHospitalListLoadingPanel" runat="server" |
| Transparency="50" |
| MinDisplayTime="500" |
| BackColor="#E1DED1" |
| EnableEmbeddedSkins="false"> |
| <table style="height: 100%; width: 100%" border="0"> |
| <tr> |
| <td width="100%" align="center" valign="middle"> |
| <img id="rajaxHospitalListLoadingPanelLogo" runat="server" src="~/App_Themes/Default/Images/Logo.gif" alt="TriCore Reference Laboratories" style="border: 0; margin-top: 64px" /><br /> |
| <img id="rajaxHospitalListLoadingPanelImage" runat="server" src="~/App_Themes/Default/Images/LoadingLargeDrip.gif" alt="Loading..." style="border: 0; margin-top: 8px" /> |
| </td> |
| </tr> |
| </table> |
| </telerik:RadAjaxLoadingPanel> |
| <h1>Hospital List</h1> |
| <telerik:RadAjaxPanel EnableAJAX="true" ID="rajaxpnlHospitalList" runat="server" ClientEvents-OnRequestStart="conditionalPostback"> |
| <div id="messageGeneral" runat="server" class="messageBox"></div> |
| <asp:ValidationSummary ID="valsumHospitalList" runat="server" |
| DisplayMode="BulletList" |
| HeaderText="Please review the following:" |
| ShowMessageBox="false" |
| ShowSummary="true" /> |
| <asp:DropDownList ID="ddlHospitalEditMode" runat="server" |
| AutoPostBack="true" |
| Visible="false" |
| onselectedindexchanged="DDLHospitalEditMode_SelectedIndexChanged"> |
| <asp:ListItem Value="EditForms" Text="Form" Selected="True" /> |
| <asp:ListItem Value="InPlace" Text="Inline" /> |
| </asp:DropDownList> |
| <telerik:RadGrid ID="rgrdHospitalList" runat="server" |
| AutoGenerateColumns="False" |
| GridLines="None" |
| AllowPaging="True" |
| PageSize="15" |
| AllowAutomaticInserts="True" |
| AllowAutomaticUpdates="True" |
| AllowAutomaticDeletes="True" |
| DataSourceID="dssqlHospitalList" |
| OnItemInserted="RGRDHospitalList_ItemInserted" |
| OnItemUpdated="RGRDHospitalList_ItemUpdated" |
| OnItemDeleted="RGRDHospitalList_ItemDeleted" |
| OnRowDrop="RGRDHospitalList_RowDrop" |
| OnItemDataBound="RGRDHospitalList_ItemDataBound" |
| OnItemCreated="RGRDHospitalList_ItemCreated" |
| OnItemCommand="RGRDHospitalList_ItemCommand" |
| ValidationSettings-EnableValidation="false"> |
| <PagerStyle Mode="NextPrevAndNumeric" /> |
| <MasterTableView |
| Width="100%" |
| CommandItemDisplay="TopAndBottom" |
| DataKeyNames="HospitalID" |
| DataSourceID="dssqlHospitalList" |
| HorizontalAlign="NotSet" |
| AutoGenerateColumns="False"> |
| <Columns> |
| <telerik:GridEditCommandColumn |
| ButtonType="ImageButton" |
| UniqueName="EditCommandColumn" |
| EditFormColumnIndex="0"> |
| <HeaderStyle |
| VerticalAlign="Bottom" |
| Wrap="false" /> |
| <ItemStyle |
| CssClass="GridEditImageButton" |
| HorizontalAlign="Left" |
| VerticalAlign="Top" /> |
| </telerik:GridEditCommandColumn> |
| <telerik:GridButtonColumn UniqueName="DeleteColumn" |
| ConfirmText="Delete this item?" |
| ConfirmDialogType="RadWindow" |
| ConfirmTitle="Delete Item" |
| ButtonType="ImageButton" |
| CommandName="Delete" |
| Text="Delete"> |
| <HeaderStyle |
| VerticalAlign="Bottom" |
| Wrap="false" /> |
| <ItemStyle |
| HorizontalAlign="Left" |
| VerticalAlign="Top" |
| CssClass="GridDeleteImageButton" /> |
| </telerik:GridButtonColumn> |
| <telerik:GridTemplateColumn UniqueName="HospitalName" |
| HeaderText="Name" |
| SortExpression="HospitalName"> |
| <ItemTemplate> |
| <asp:Label ID="lblName" runat="server" |
| Text='<%# Eval("HospitalName") %>' /> |
| </ItemTemplate> |
| <HeaderStyle |
| VerticalAlign="Bottom" |
| Wrap="false" /> |
| <ItemStyle |
| VerticalAlign="Top" |
| HorizontalAlign="Left" |
| Wrap="false" /> |
| <EditItemTemplate> |
| <telerik:RadTextBox ID="txbHospitalName" runat="server" |
| Width="200px" |
| Text='<%# Bind("HospitalName") %>' /> |
| <asp:RequiredFieldValidator ID="valreqHospitalName" runat="server" |
| ControlToValidate="txbHospitalName" |
| EnableClientScript="false" |
| Display="Dynamic" |
| ErrorMessage="Name is required." |
| SetFocusOnError="true"><img src="../Images/Indicators/ValidationException.gif" class="validationException" alt="" /></asp:RequiredFieldValidator> |
| </EditItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridCheckBoxColumn UniqueName="IsDefault" |
| DataField="IsDefault" |
| HeaderText="Default" |
| SortExpression="IsDefault" |
| EditFormColumnIndex="0" |
| Visible="false"> |
| <HeaderStyle |
| VerticalAlign="Bottom" |
| Wrap="true" /> |
| <ItemStyle |
| HorizontalAlign="Center" |
| VerticalAlign="Top" /> |
| </telerik:GridCheckBoxColumn> |
| <telerik:GridTemplateColumn UniqueName="IsDefaultIndicator" |
| HeaderText="Default"> |
| <ItemTemplate> |
| <asp:Image ID="imgIsDefault" runat="server" |
| BorderWidth="0px" |
| Height="16px" |
| Width="16px" |
| ImageUrl='<%# Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "IsDefault"))? "../Images/Indicators/checkmark.png" : "../Images/Indicators/cross.png" %>' |
| AlternateText="Default" |
| Style="float: right; cursor: pointer;"> |
| </asp:Image> |
| </ItemTemplate> |
| <HeaderStyle |
| VerticalAlign="Bottom" |
| Wrap="true" /> |
| <ItemStyle |
| HorizontalAlign="Center" |
| VerticalAlign="Top" /> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBinaryImageColumn |
| DataField="TreeImage" |
| HeaderText="Image" |
| SortExpression="TreeImage" |
| UniqueName="TreeImageUpload" |
| EditFormColumnIndex="0" |
| ColumnEditorID="grdbimgTreeImageColumnEditor" |
| ImageAlign="Middle" |
| ResizeMode="None" |
| DataAlternateTextField="HospitalName" |
| DataAlternateTextFormatString="Image of {0}"> |
| <HeaderStyle |
| VerticalAlign="Bottom" |
| Wrap="true" /> |
| <ItemStyle |
| HorizontalAlign="Center" |
| VerticalAlign="Top" /> |
| </telerik:GridBinaryImageColumn> |
| <telerik:GridCheckBoxColumn |
| DataField="TreeImageDeletion" |
| HeaderText="Delete Tree Image" |
| SortExpression="TreeImageDeletion" |
| UniqueName="TreeImageDeletion" |
| EditFormColumnIndex="0" Visible="false"> |
| <HeaderStyle |
| VerticalAlign="Top" |
| Wrap="false" /> |
| <ItemStyle |
| HorizontalAlign="Center" |
| VerticalAlign="Top" /> |
| </telerik:GridCheckBoxColumn> |
| <telerik:GridBinaryImageColumn |
| DataField="TreeExpandedImage" |
| HeaderText="Expanded" |
| SortExpression="TreeExpandedImage" |
| UniqueName="TreeExpandedImageUpload" |
| EditFormColumnIndex="0" |
| ColumnEditorID="grdbimgTreeExpandedImageColumnEditor" |
| ImageAlign="Middle" |
| ResizeMode="None" |
| DataAlternateTextField="HospitalName" |
| DataAlternateTextFormatString="Image of {0}"> |
| <HeaderStyle |
| VerticalAlign="Bottom" |
| Wrap="false" /> |
| <ItemStyle |
| HorizontalAlign="Center" |
| VerticalAlign="Top" /> |
| </telerik:GridBinaryImageColumn> |
| <telerik:GridCheckBoxColumn UniqueName="TreeExpandedImageDeletion" |
| DataField="TreeExpandedImageDeletion" |
| HeaderText="Delete Tree Expanded Image" |
| SortExpression="TreeExpandedImageDeletion" |
| EditFormColumnIndex="0" Visible="false"> |
| <HeaderStyle |
| VerticalAlign="Bottom" |
| Wrap="false" /> |
| <ItemStyle |
| HorizontalAlign="Center" |
| VerticalAlign="Top" /> |
| </telerik:GridCheckBoxColumn> |
| <telerik:GridBinaryImageColumn |
| DataField="Icon32x32Image" |
| HeaderText="Icon 32x32 Image" |
| SortExpression="Icon32x32Image" |
| UniqueName="Icon32x32ImageUpload" |
| EditFormColumnIndex="0" |
| ColumnEditorID="grdbimgIcon32x32ImageColumnEditor" |
| ImageAlign="Middle" |
| ResizeMode="None" |
| DataAlternateTextField="HospitalName" |
| DataAlternateTextFormatString="Image of {0}"> |
| <HeaderStyle |
| VerticalAlign="Bottom" |
| Wrap="false" /> |
| <ItemStyle |
| HorizontalAlign="Center" |
| VerticalAlign="Top" /> |
| </telerik:GridBinaryImageColumn> |
| <telerik:GridCheckBoxColumn UniqueName="Icon32x32ImageDeletion" |
| DataField="Icon32x32ImageDeletion" |
| HeaderText="Delete Icon 32x32 Image" |
| SortExpression="Icon32x32ImageDeletion" |
| EditFormColumnIndex="0" Visible="false"> |
| <HeaderStyle |
| VerticalAlign="Bottom" |
| Wrap="false" /> |
| <ItemStyle |
| HorizontalAlign="Center" |
| VerticalAlign="Top" /> |
| </telerik:GridCheckBoxColumn> |
| </Columns> |
| <EditFormSettings |
| ColumnNumber="1" |
| CaptionDataField="HospitalName" |
| CaptionFormatString="Edit Properties of Hospital {0}"> |
| <FormTableItemStyle Wrap="False" /> |
| <FormCaptionStyle CssClass="EditFormHeader" /> |
| <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="16" BackColor="White" Width="100%" /> |
| <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" /> |
| <FormTableAlternatingItemStyle Wrap="False" /> |
| <EditColumn |
| ButtonType="PushButton" |
| CancelText="Cancel" |
| InsertText="Add" |
| UpdateText="Save" |
| UniqueName="EditCommandColumn1" /> |
| <FormTableButtonRowStyle HorizontalAlign="Right" /> |
| </EditFormSettings> |
| <NoRecordsTemplate> |
| <div> |
| No data was returned. |
| </div> |
| </NoRecordsTemplate> |
| </MasterTableView> |
| <ClientSettings AllowRowsDragDrop="true"> |
| <ClientEvents |
| OnRowDblClick="rgrdHospitalList_RowDblClick" |
| OnRowDropping="rgrdHospitalList_RowDropping" /> |
| <Selecting AllowRowSelect="True" EnableDragToSelectRows="false" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
| </telerik:RadAjaxPanel> |
| <telerik:GridBinaryImageColumnEditor ID="grdbimgTreeImageColumnEditor" runat="server" /> |
| <telerik:GridBinaryImageColumnEditor ID="grdbimgTreeExpandedImageColumnEditor" runat="server" /> |
| <telerik:GridBinaryImageColumnEditor ID="grdbimgIcon32x32ImageColumnEditor" runat="server" /> |
| <telerik:RadWindowManager ID="rwmgrHospitalList" runat="server" /> |
| <asp:SqlDataSource ID="dssqlHospitalList" runat="server" |
| ConnectionString="<%$ ConnectionStrings:DoSConnectionString %>" |
| ProviderName="System.Data.SqlClient" |
| InsertCommand="INSERT INTO [Hospital]([HospitalName], [IsDefault], [TreeImage], [TreeExpandedImage], [Icon32x32Image]) VALUES (@HospitalName, @IsDefault, @TreeImage, @TreeExpandedImage, @Icon32x32Image)" |
| InsertCommandType="Text" |
| SelectCommand="SELECT [HospitalID], [HospitalName], [IsDefault], [TreeImage], [TreeExpandedImage], [Icon32x32Image], (SELECT CONVERT(BIT,0)) AS TreeImageDeletion, (SELECT CONVERT(BIT,0)) AS TreeExpandedImageDeletion, (SELECT CONVERT(BIT,0)) AS Icon32x32ImageDeletion FROM [Hospital] ORDER BY [OrderSequence] ASC" |
| SelectCommandType="Text" |
| UpdateCommand="IF @TreeImageDeletion = 1 BEGIN UPDATE [Hospital] SET [TreeImage] = NULL WHERE [HospitalID] = @original_HospitalID END IF @TreeExpandedImageDeletion = 1 BEGIN UPDATE [Hospital] SET [TreeExpandedImage] = NULL WHERE [HospitalID] = @original_HospitalID END IF @Icon32x32ImageDeletion = 1 BEGIN UPDATE [Hospital] SET [Icon32x32Image] = NULL WHERE [HospitalID] = @original_HospitalID END UPDATE [Hospital] SET [HospitalName] = @HospitalName, [IsDefault] = @IsDefault, [TreeImage] = ISNULL(@TreeImage, [TreeImage]), [TreeExpandedImage] = ISNULL(@TreeExpandedImage, [TreeExpandedImage]), [Icon32x32Image] = ISNULL(@Icon32x32Image, [Icon32x32Image]) WHERE [HospitalID] = @original_HospitalID" |
| UpdateCommandType="Text" |
| DeleteCommand="DELETE FROM [Hospital] WHERE [HospitalID] = @original_HospitalID" |
| DeleteCommandType="Text" |
| OldValuesParameterFormatString="original_{0}" |
| ConflictDetection="OverwriteChanges"> |
| <InsertParameters> |
| <asp:Parameter Name="HospitalName" Type="String" /> |
| <asp:Parameter Name="IsDefault" Type="Boolean" /> |
| <asp:Parameter Name="TreeImage" DbType="Binary" /> |
| <asp:Parameter Name="TreeExpandedImage" DbType="Binary" /> |
| <asp:Parameter Name="Icon32x32Image" DbType="Binary" /> |
| </InsertParameters> |
| <UpdateParameters> |
| <asp:Parameter Name="HospitalName" Type="String" /> |
| <asp:Parameter Name="IsDefault" Type="Boolean" /> |
| <asp:Parameter Name="TreeImage" DbType="Binary" /> |
| <asp:Parameter Name="TreeExpandedImage" DbType="Binary" /> |
| <asp:Parameter Name="Icon32x32Image" DbType="Binary" /> |
| <asp:Parameter Name="TreeImageDeletion" Type="Boolean" /> |
| <asp:Parameter Name="TreeExpandedImageDeletion" Type="Boolean" /> |
| <asp:Parameter Name="Icon32x32ImageDeletion" Type="Boolean" /> |
| <asp:Parameter Name="original_HospitalID" Type="Int32" /> |
| </UpdateParameters> |
| <DeleteParameters> |
| <asp:Parameter Name="original_HospitalID" Type="Int32" /> |
| </DeleteParameters> |
| </asp:SqlDataSource> |
| <asp:SqlDataSource ID="dssqlHospitalListOrderSequence" runat="server" |
| ConnectionString="<%$ ConnectionStrings:DoSConnectionString %>" |
| ProviderName="System.Data.SqlClient" |
| SelectCommand="SELECT [HospitalID] FROM [Hospital] ORDER BY [OrderSequence] ASC" |
| SelectCommandType="Text" |
| UpdateCommand="UpdateHospitalOrderSequence" |
| UpdateCommandType="StoredProcedure" |
| OldValuesParameterFormatString="original_{0}" |
| ConflictDetection="OverwriteChanges"> |
| <UpdateParameters> |
| <asp:Parameter Name="original_HospitalID" Type="Int32" /> |
| <asp:Parameter Name="CurrentHospitalID" Type="Int32" /> |
| <asp:Parameter Name="DestinationHospitalID" Type="Int32" /> |
| <asp:Parameter Name="Position" Type="Int32" /> |
| </UpdateParameters> |
| </asp:SqlDataSource> |
| </asp:Content> |
CS Code Behind Page:
| //----------------------------------------------------------------------- |
| // <copyright file="HospitalList.aspx.cs" company="TriCore Reference Laboratories"> |
| // Copyright (c) TriCore Reference Laboratories. All rights reserved. |
| // </copyright> |
| //----------------------------------------------------------------------- |
| 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; |
| /// <summary> |
| /// Represents a Page_HospitalList. |
| /// </summary> |
| public partial class Page_HospitalList : PageBase |
| { |
| /// <summary> |
| /// The Page_Load event. |
| /// </summary> |
| /// <param name="sender">The object raising the event.</param> |
| /// <param name="e">The event arguments.</param> |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| // Clear the message for the first time. |
| DoSWebApp.Non_App_Code.MessageBox.ClearMsg(this.messageGeneral); |
| if (!this.IsPostBack) |
| { |
| // Set the grid edit mode according to the selection |
| switch (this.ddlHospitalEditMode.SelectedValue) |
| { |
| case "EditForms": |
| { |
| this.rgrdHospitalList.MasterTableView.EditMode = GridEditMode.EditForms; |
| break; |
| } |
| case "InPlace": |
| { |
| this.rgrdHospitalList.MasterTableView.EditMode = GridEditMode.InPlace; |
| break; |
| } |
| } |
| } |
| } |
| /// <summary> |
| /// This event fires when the grid has inserted an item. |
| /// </summary> |
| /// <param name="sender">The object raising the event.</param> |
| /// <param name="e">The event arguments.</param> |
| protected void RGRDHospitalList_ItemInserted(object sender, GridInsertedEventArgs e) |
| { |
| if (e.Exception != null) |
| { |
| e.ExceptionHandled = true; |
| DoSWebApp.Non_App_Code.MessageBox.DisplayMsg( |
| this.messageGeneral, |
| "Hospital cannot be added. Reason: " + e.Exception.Message, |
| MessageBoxTypeEnum.Failure); |
| } |
| else |
| { |
| DoSWebApp.Non_App_Code.MessageBox.DisplayMsg( |
| this.messageGeneral, |
| "Hospital added!", |
| MessageBoxTypeEnum.Success); |
| } |
| } |
| /// <summary> |
| /// This event fires when the grid has updated an item. |
| /// </summary> |
| /// <param name="sender">The object raising the event.</param> |
| /// <param name="e">The event arguments.</param> |
| protected void RGRDHospitalList_ItemUpdated(object sender, Telerik.Web.UI.GridUpdatedEventArgs e) |
| { |
| GridEditableItem item = (GridEditableItem)e.Item; |
| string id = Convert.ToString(item.GetDataKeyValue("HospitalID")); |
| if (e.Exception != null) |
| { |
| e.KeepInEditMode = true; |
| e.ExceptionHandled = true; |
| DoSWebApp.Non_App_Code.MessageBox.DisplayMsg( |
| this.messageGeneral, |
| "Hospital cannot be saved. Reason: " + e.Exception.Message, |
| MessageBoxTypeEnum.Failure); |
| } |
| else |
| { |
| DoSWebApp.Non_App_Code.MessageBox.DisplayMsg( |
| this.messageGeneral, |
| "Hospital saved!", |
| MessageBoxTypeEnum.Success); |
| } |
| } |
| /// <summary> |
| /// This event fires when the grid has deleted an item. |
| /// </summary> |
| /// <param name="sender">The object raising the event.</param> |
| /// <param name="e">The event arguments.</param> |
| protected void RGRDHospitalList_ItemDeleted(object sender, GridDeletedEventArgs e) |
| { |
| GridDataItem dataItem = (GridDataItem)e.Item; |
| string id = Convert.ToString(dataItem.GetDataKeyValue("HospitalID")); |
| if (e.Exception != null) |
| { |
| e.ExceptionHandled = true; |
| DoSWebApp.Non_App_Code.MessageBox.DisplayMsg( |
| this.messageGeneral, |
| "Hospital cannot be removed. Reason: " + e.Exception.Message, |
| MessageBoxTypeEnum.Failure); |
| } |
| else |
| { |
| DoSWebApp.Non_App_Code.MessageBox.DisplayMsg( |
| this.messageGeneral, |
| "Hospital removed!", |
| MessageBoxTypeEnum.Success); |
| } |
| } |
| /// <summary> |
| /// This event fires when the dropdownlist index has changed. |
| /// </summary> |
| /// <param name="sender">The object raising the event.</param> |
| /// <param name="e">The event arguments.</param> |
| protected void DDLHospitalEditMode_SelectedIndexChanged(object sender, EventArgs e) |
| { |
| // Determin what was selected and change the grid properties based on the selection |
| switch ((sender as DropDownList).SelectedValue) |
| { |
| case "EditForms": |
| { |
| rgrdHospitalList.MasterTableView.EditMode = GridEditMode.EditForms; |
| break; |
| } |
| case "InPlace": |
| { |
| rgrdHospitalList.MasterTableView.EditMode = GridEditMode.InPlace; |
| break; |
| } |
| } |
| // Rebind so that the grid refreshes |
| rgrdHospitalList.Rebind(); |
| } |
| /// <summary> |
| /// This event fires when a row has been dropped. |
| /// </summary> |
| /// <param name="sender">The object raising the event.</param> |
| /// <param name="e">The event arguments.</param> |
| protected void RGRDHospitalList_RowDrop(object sender, GridDragDropEventArgs e) |
| { |
| try |
| { |
| if (e.DraggedItems.Count > 0 && e.DestDataItem != null) |
| { |
| int draggedIndex = (int)e.DraggedItems[0].GetDataKeyValue("HospitalID"); |
| int destinationIndex = (int)e.DestDataItem.GetDataKeyValue("HospitalID"); |
| dssqlHospitalListOrderSequence.UpdateParameters["DestinationHospitalID"].DefaultValue = destinationIndex.ToString(); |
| dssqlHospitalListOrderSequence.UpdateParameters["CurrentHospitalID"].DefaultValue = draggedIndex.ToString(); |
| if (e.DropPosition == GridItemDropPosition.Below) |
| { |
| dssqlHospitalListOrderSequence.UpdateParameters["Position"].DefaultValue = "1"; |
| } |
| dssqlHospitalListOrderSequence.Update(); |
| dssqlHospitalListOrderSequence.Select(new DataSourceSelectArguments()); |
| rgrdHospitalList.Rebind(); |
| DoSWebApp.Non_App_Code.MessageBox.DisplayMsg( |
| this.messageGeneral, |
| "Hospital sequence saved!", |
| MessageBoxTypeEnum.Success); |
| } |
| } |
| catch (Exception ex) |
| { |
| if (ex != null) |
| { |
| DoSWebApp.Non_App_Code.MessageBox.DisplayMsg( |
| this.messageGeneral, |
| "Hospital sequence cannot be saved. Reason: " + ex.Message, |
| MessageBoxTypeEnum.Failure); |
| } |
| else |
| { |
| throw new Exception("Hospital sequence cannot be saved."); |
| } |
| } |
| } |
| /// <summary> |
| /// This event fires when an item is being databound. |
| /// </summary> |
| /// <param name="sender">The object raising the event.</param> |
| /// <param name="e">The event arguments.</param> |
| protected void RGRDHospitalList_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
| { |
| GridBinaryImageColumnEditor editorTreeImage = ((GridEditableItem)e.Item).EditManager.GetColumnEditor("TreeImageUpload") as GridBinaryImageColumnEditor; |
| rajaxpnlHospitalList.ResponseScripts.Add(string.Format("window['UploadId'] = '{0}';", editorTreeImage.RadUploadControl.ClientID)); |
| GridBinaryImageColumnEditor editorTreeExpandedImage = ((GridEditableItem)e.Item).EditManager.GetColumnEditor("TreeExpandedImageUpload") as GridBinaryImageColumnEditor; |
| rajaxpnlHospitalList.ResponseScripts.Add(string.Format("window['UploadId'] = '{0}';", editorTreeExpandedImage.RadUploadControl.ClientID)); |
| GridBinaryImageColumnEditor editorIcon32x32Image = ((GridEditableItem)e.Item).EditManager.GetColumnEditor("Icon32x32ImageUpload") as GridBinaryImageColumnEditor; |
| rajaxpnlHospitalList.ResponseScripts.Add(string.Format("window['UploadId'] = '{0}';", editorIcon32x32Image.RadUploadControl.ClientID)); |
| if (e.Item.OwnerTableView.IsItemInserted) |
| { |
| // item is about to be inserted |
| } |
| else |
| { |
| // item is about to be edited |
| } |
| } |
| if (e.Item is GridDataItem) |
| { |
| GridDataItem dataItem = (GridDataItem)e.Item; |
| RadBinaryImage imgTreeImage = (RadBinaryImage)dataItem["TreeImageUpload"].Controls[0]; |
| if (imgTreeImage.ImageUrl == string.Empty) |
| { |
| imgTreeImage.Visible = false; |
| LiteralControl literal = new LiteralControl(); |
| literal.Text = "N/A"; |
| dataItem["TreeImageUpload"].Controls.Add(literal); |
| } |
| RadBinaryImage imgTreeExpandedImage = (RadBinaryImage)dataItem["TreeExpandedImageUpload"].Controls[0]; |
| if (imgTreeExpandedImage.ImageUrl == string.Empty) |
| { |
| imgTreeExpandedImage.Visible = false; |
| LiteralControl literal = new LiteralControl(); |
| literal.Text = "N/A"; |
| dataItem["TreeExpandedImageUpload"].Controls.Add(literal); |
| } |
| RadBinaryImage imgIcon32x32Image = (RadBinaryImage)dataItem["Icon32x32ImageUpload"].Controls[0]; |
| if (imgIcon32x32Image.ImageUrl == string.Empty) |
| { |
| imgIcon32x32Image.Visible = false; |
| LiteralControl literal = new LiteralControl(); |
| literal.Text = "N/A"; |
| dataItem["Icon32x32ImageUpload"].Controls.Add(literal); |
| } |
| } |
| } |
| /// <summary> |
| /// This event fires when an item is being created. |
| /// </summary> |
| /// <param name="sender">The object raising the event.</param> |
| /// <param name="e">The event arguments.</param> |
| protected void RGRDHospitalList_ItemCreated(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
| { |
| GridBinaryImageColumnEditor editorTreeImage = ((GridEditableItem)e.Item).EditManager.GetColumnEditor("TreeImageUpload") as GridBinaryImageColumnEditor; |
| TableCell cellTreeImage = (TableCell)editorTreeImage.RadUploadControl.Parent; |
| CustomValidator validatorTreeImage = new CustomValidator(); |
| validatorTreeImage.ErrorMessage = "Tree Image is required"; |
| validatorTreeImage.ClientValidationFunction = "validateTreeImageUpload"; |
| validatorTreeImage.Display = ValidatorDisplay.Dynamic; |
| cellTreeImage.Controls.Add(validatorTreeImage); |
| GridBinaryImageColumnEditor editorTreeExpandedImage = ((GridEditableItem)e.Item).EditManager.GetColumnEditor("TreeExpandedImageUpload") as GridBinaryImageColumnEditor; |
| TableCell cellTreeExpandedImage = (TableCell)editorTreeExpandedImage.RadUploadControl.Parent; |
| CustomValidator validatorTreeExpandedImage = new CustomValidator(); |
| validatorTreeExpandedImage.ErrorMessage = "Tree Expanded Image is required"; |
| validatorTreeExpandedImage.ClientValidationFunction = "validateTreeExpandedImageUpload"; |
| validatorTreeExpandedImage.Display = ValidatorDisplay.Dynamic; |
| cellTreeExpandedImage.Controls.Add(validatorTreeExpandedImage); |
| GridBinaryImageColumnEditor editorIcon32x32Image = ((GridEditableItem)e.Item).EditManager.GetColumnEditor("Icon32x32ImageUpload") as GridBinaryImageColumnEditor; |
| TableCell cellIcon32x32Image = (TableCell)editorIcon32x32Image.RadUploadControl.Parent; |
| CustomValidator validatorIcon32x32Image = new CustomValidator(); |
| validatorIcon32x32Image.ErrorMessage = "Icon 32x32 Image is required"; |
| validatorIcon32x32Image.ClientValidationFunction = "validateIcon32x32ImageUpload"; |
| validatorIcon32x32Image.Display = ValidatorDisplay.Dynamic; |
| cellIcon32x32Image.Controls.Add(validatorIcon32x32Image); |
| GridEditFormItem item = (GridEditFormItem)e.Item; |
| // GridEditFormItem editItem = (GridEditFormItem)e.Item; |
| if (e.Item.OwnerTableView.IsItemInserted) |
| { |
| // item is about to be inserted |
| // CheckBox chkbxTreeImageDeletion = (CheckBox)insertItem["TreeImageDeletion"].Controls[0]; |
| item["TreeImageDeletion"].Visible = false; |
| // chkbxTreeImageDeletion.Style.Add("display", "none"); |
| item["TreeImageDeletion"].Parent.Visible = false; |
| // CheckBox chkbxTreeExpandedImageDeletion = (CheckBox)insertItem["TreeExpandedImageDeletion"].Controls[0]; |
| item["TreeExpandedImageDeletion"].Visible = false; |
| // chkbxTreeExpandedImageDeletion.Style.Add("display", "none"); |
| item["TreeExpandedImageDeletion"].Parent.Visible = false; |
| // CheckBox chkbxIcon32x32ImageDeletion = (CheckBox)insertItem["Icon32x32ImageDeletion"].Controls[0]; |
| item["Icon32x32ImageDeletion"].Visible = false; |
| // chkbxIcon32x32ImageDeletion.Style.Add("display", "none"); |
| item["Icon32x32ImageDeletion"].Parent.Visible = false; |
| } |
| else |
| { |
| // item is about to be edited |
| item["TreeImageDeletion"].Visible = true; |
| item["TreeImageDeletion"].Parent.Visible = true; |
| item["TreeExpandedImageDeletion"].Visible = true; |
| item["TreeExpandedImageDeletion"].Parent.Visible = true; |
| item["Icon32x32ImageDeletion"].Visible = true; |
| item["Icon32x32ImageDeletion"].Parent.Visible = true; |
| } |
| } |
| } |
| /// <summary> |
| /// This event fires when an command is being executed. |
| /// </summary> |
| /// <param name="sender">The object raising the event.</param> |
| /// <param name="e">The event arguments.</param> |
| protected void RGRDHospitalList_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) |
| { |
| RadGrid grid = sender as RadGrid; |
| // This is when Add New Item is clicked. |
| if (e.CommandName == RadGrid.InitInsertCommandName) |
| { |
| if (grid.EditItems.Count > 0) |
| { |
| grid.MasterTableView.ClearEditItems(); |
| } |
| } |
| // This is when Add is executed. |
| if (e.CommandName == RadGrid.PerformInsertCommandName) |
| { |
| Page.Validate(); |
| if (this.IsValid) |
| { |
| grid.MasterTableView.ClearEditItems(); |
| } |
| else |
| { |
| // To display the confirmation messages |
| DoSWebApp.Non_App_Code.MessageBox.DisplayMsg( |
| this.messageGeneral, |
| this.valsumHospitalList, |
| MessageBoxTypeEnum.Alert); |
| e.Canceled = true; |
| } |
| } |
| // This is when Edit is clicked. |
| if (e.CommandName == RadGrid.EditCommandName) |
| { |
| e.Item.OwnerTableView.IsItemInserted = false; |
| } |
| // This is when the Edit is executed |
| if (e.CommandName == RadGrid.UpdateCommandName) |
| { |
| if (this.IsValid) |
| { |
| e.Item.OwnerTableView.IsItemInserted = false; |
| } |
| else |
| { |
| // To display the confirmation messages |
| DoSWebApp.Non_App_Code.MessageBox.DisplayMsg( |
| this.messageGeneral, |
| this.valsumHospitalList, |
| MessageBoxTypeEnum.Alert); |
| e.Canceled = true; |
| } |
| } |
| } |
| /// <summary> |
| /// This trims text and places a ... at the end of the text. |
| /// </summary> |
| /// <param name="content">The content being trimmed.</param> |
| /// <param name="concatEndpoint">The endpoint where the ... needs to be added.</param> |
| /// <param name="endStringInidcator">The ... or something else.</param> |
| /// <returns>The trimed value.</returns> |
| protected string TrimContent(string content, int concatEndpoint, string endStringInidcator) |
| { |
| if (!string.IsNullOrEmpty(content) && content.Length > concatEndpoint) |
| { |
| return string.Concat(content.Substring(0, concatEndpoint), endStringInidcator); |
| } |
| return content; |
| } |
| } |
Let me know if what I have provided to help people understand this problem is not sufficiant.
- Randy Bigbie