Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
46 views
Hi,
I am trying to localize the contents of the Grid Pager and this is the code i have in the Item Data Bound event handler

if (e.Item is GridPagerItem) //set the appropriate values in the Pager drop down
{
                    GridPagerItem gridPagerItem= e.Item as GridPagerItem;
  
                    Label pageSizeLabel = gridPagerItem.FindControl("ChangePageSizeLabel") as Label;
                    if (null != pageSizeLabel)
                        pageSizeLabel.Text = "Number of Items:";
  
                    GridUsersList.PagerStyle.PagerTextFormat = "{4}{5} " + "items in " + "{1}" + " pages";
                    GridUsersList.PagerStyle.NextPageToolTip = "Next Page";
                    GridUsersList.PagerStyle.PrevPageToolTip = "Previous Page";
                    GridUsersList.PagerStyle.LastPageToolTip = "Last Page";
                    GridUsersList.PagerStyle.FirstPageToolTip = "First Page";
}

This works fine, but i have over 20 grids in different web pages in my application. Is there any way to standardize this instead of making this change in 20 different places?

Ullas
Mira
Telerik team
 answered on 08 Jul 2011
1 answer
257 views
I have a web user control that allows the user to run one of several available canned reports from a rad combo box.  I'm able to specify which report to run and specify a few basic criteria when producing the first report.  Afterwards, however, if I select a different report (which programmatically generates the columns in a rad grid and selects the appropriate data source) after returning to the criteria screen I receive this error:

Error: Sys.WebForms.PageRequestManagerServerErrorException: There was a problem extracting DataKeyValues from the DataSource. Please ensure that DataKeyNames are specified correctly and all fields specified exist in the DataSource.

After further investigation, it seems as if the DataKeyValues the grid is expecting "lags" behind because I can keep running the same report with different criteria so long as the report type remains the same.  As soon as I change report types (which use differnet DataKeyValues), the grid does not appear to update with those values (still uses the DataKeyValues from the previous report) and fails.  I'm hoping someone else can shed some light on the situation.  I've provided my interface and server-side code below.

User Control Interface:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ReportManager.ascx.cs" Inherits="AZ.SA.RL.App.ProgramManagement.Controls.ReportManager" %>
 
<telerik:RadCodeBlock ID="ControlScripts" runat="server">
<script type="text/javascript">
    function onRequestStart(sender, args) {
        if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||
                    args.get_eventTarget().indexOf("ExportToWordButton") >= 0 ||
                    args.get_eventTarget().indexOf("ExportToCsvButton") >= 0) {
            args.set_enableAjax(false);
        }
    }
</script>
</telerik:RadCodeBlock>
 
<telerik:RadAjaxManager ID="Report_ScriptManager" runat="server">
    <ClientEvents OnRequestStart="onRequestStart" />
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="Result_Grid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="Result_Grid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
 
<telerik:RadAjaxPanel ID="ControlContainer_AjaxPanel" runat="server" CssClass="ContentBlock" Style="width:auto">
    <h3><asp:Label ID="ControlHeader_Label" runat="server" Text="Quick Report" /></h3>
    <asp:ValidationSummary ID="QuickReport_ValidationSummary"
            runat="server"
            ShowMessageBox="false"
            ShowSummary="true"
            ValidationGroup="QuickReportValidation" />        
    <asp:Panel ID="QuickReport_Panel" runat="server" Visible="true">       
        <ul>
            <li>
                <asp:Label ID="QuickReportType_Label" runat="server" AssociatedControlID="QuickReportType_Combobox" Text="Quick Report" />
                <telerik:RadComboBox ID="QuickReportType_Combobox" runat="server" />
            </li>
        </ul>
        <ul>
            <li>
                <asp:Label ID="StartDate_Label" runat="server" AssociatedControlID="QuickReportStartDate_DatePicker" Text="Start Date" />
                <telerik:RadDatePicker ID="QuickReportStartDate_DatePicker" runat="server">
                    <ShowAnimation Type="Fade" Duration="500" />
                    <HideAnimation Type="Fade" Duration="500" />
                </telerik:RadDatePicker>
                <asp:RequiredFieldValidator ID="QuickReportStartDate_RequiredField"
                    runat="server"
                    ControlToValidate="QuickReportStartDate_DatePicker"
                    CssClass="Validator"
                    Display="Dynamic"
                    ErrorMessage="Please specify a start date in the Start Date field."                                
                    SetFocusOnError="true"
                    Text="*"
                    ValidationGroup="QuickReportValidation" />
                <asp:CompareValidator ID="QuickReportStartDate_StartDateBeforeEndDate"
                    runat="server"
                    ControlToValidate="QuickReportStartDate_DatePicker"
                    ControlToCompare="QuickReportEndDate_DatePicker"
                    CssClass="Validator"
                    Display="Dynamic"
                    ErrorMessage="The start date of a report must come before its end date."
                    Operator="LessThanEqual"
                    SetFocusOnError="true"
                    Text="*"
                    Type="Date"
                    ValidationGroup="QuickReportValidation" />                   
            </li>
        </ul>
        <ul>
            <li>
                <asp:Label ID="EndDate_Label" runat="server" AssociatedControlID="QuickReportEndDate_DatePicker" Text="End Date" />
                <telerik:RadDatePicker ID="QuickReportEndDate_DatePicker" runat="server">
                    <ShowAnimation Type="Fade" Duration="500" />
                    <HideAnimation Type="Fade" Duration="500" />
                </telerik:RadDatePicker>
                <asp:RequiredFieldValidator ID="QuickReportEndDate_RequiredField"
                    runat="server"
                    ControlToValidate="QuickReportEndDate_DatePicker"
                    CssClass="Validator"
                    Display="Dynamic"
                    ErrorMessage="Please specify an end date in the Start Date field."                                
                    SetFocusOnError="true"
                    Text="*"
                    ValidationGroup="QuickReportValidation" />
            </li>
        </ul>
        <ul>
            <li>
                <asp:Label ID="Options_Label" runat="server" AssociatedControlID="QuickReportIncludeQuickReport_CheckBoxList" Text="Options" />
                <div class="CheckBoxList">
                    <asp:CheckBoxList ID="QuickReportIncludeQuickReport_CheckBoxList"
                        runat="server"
                        RepeatLayout="UnorderedList">
                        <asp:ListItem Text="Include Quick Plans" Value="0" />
                    </asp:CheckBoxList>
                </div>        
            </li>
        </ul>                               
        <asp:Button ID="RunReport_Button"
            runat="server"
            CausesValidation="true"
            OnClick="RunReport_Button_Click"
            Text="Run Report"            
            ValidationGroup="QuickReportValidation" />
    </asp:Panel>
 
    <asp:Panel ID="CustomReport_Panel" runat="server">   
    </asp:Panel>
 
    <asp:Panel ID="Result_Panel" runat="server" Visible="false">       
        <telerik:RadGrid ID="Result_Grid"
            runat="server"
            ExportSettings-ExportOnlyData="true"
            ExportSettings-OpenInNewWindow="true"
            ExportSettings-IgnorePaging = "true"
            ExportSettings-HideStructureColumns="true"                                                
            OnNeedDataSource="Result_Grid_NeedDataSource"
            OnDetailTableDataBind="Result_Grid_DetailTableDataBind"
            OnGridExporting="Result_Grid_GridExporting"
            OnItemDataBound="Result_Grid_ItemDataBound"                     
            Skin="Black">
            <MasterTableView
                AllowPaging="true"
                AutoGenerateColumns="false"               
                CommandItemDisplay = "Top"
                CommandItemSettings-ShowExportToCsvButton="false"
                CommandItemSettings-ShowExportToExcelButton="true"
                CommandItemSettings-ShowExportToPdfButton="false"
                CommandItemSettings-ShowExportToWordButton="true"
                CommandItemSettings-ShowAddNewRecordButton="false"
                GroupLoadMode="Server"
                Name="ReportResults"                
                HierarchyDefaultExpanded="true"
                HierarchyLoadMode="ServerBind"               
                PagerStyle-AlwaysVisible="true"
                PagerStyle-Mode="NextPrevNumericAndAdvanced"
                PagerStyle-Position="Top"
                PageSize="30"               
                TableLayout="Fixed">
                <DetailTables>
                    <telerik:GridTableView 
                        AutoGenerateColumns="true"                   
                        Name="DetailResults"
                        OnDataBound="Result_DetailGrid_OnDataBound"
                        OnPreRender="Result_DetailGrid_PreRender"
                        BorderStyle="None"                       
                        ShowHeader="false"
                        TableLayout="Fixed">                       
                    </telerik:GridTableView>                   
                </DetailTables>                                
            </MasterTableView>
        </telerik:RadGrid>
    </asp:Panel>   
</telerik:RadAjaxPanel>

Page Interface:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ReportView.ascx.cs" Inherits="AZ.SA.RL.App.ProgramManagement.ReportView" %>
<%@ Register Src="~/Controls/ReportManager.ascx" TagName="ReportManager" TagPrefix="pm"  %>
 
<telerik:RadAjaxManagerProxy ID="Program_AjaxManager" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="Report_Toolbar_ButtonClick">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="Report_ReportManager" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>
 
<asp:UpdatePanel ID="Toolbar_AjaxPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
    <telerik:RadToolBar ID="Report_Toolbar"
        runat="server"
        Skin="Black"
        BorderStyle="None"
        BorderWidth="0"
        OnButtonClick="Report_Toolbar_ButtonClick"
        Width="100%">
        <Items>           
            <telerik:RadToolBarDropDown Text="New Report" DropDownWidth="150px">
                <Buttons>
                    <telerik:RadToolBarButton Text="Quick Report" CommandName="NEW" Value="Quick" />
                    <telerik:RadToolBarButton Text="Custom Report" CommandName="NEW" Value="Custom" Enabled="false" Visible="false" />
                </Buttons>
            </telerik:RadToolBarDropDown>
            <telerik:RadToolBarButton IsSeparator="true" Value="Sep1" />
            <telerik:RadToolBarButton Text="Criteria" CommandName="CRITERIA" Checked="true" CheckOnClick="true" Group="PlanType" />
            <telerik:RadToolBarButton Text="Results" CommandName="RESULTS" Checked="false" CheckOnClick="true" Group="PlanType" />           
        </Items>   
    </telerik:RadToolBar>
</ContentTemplate>
</asp:UpdatePanel>
 
<asp:UpdatePanel ID="Content_AjaxPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
    <div class="ContentContainer">
        <pm:ReportManager ID="Report_ReportManager" runat="server" />
    </div>
</ContentTemplate>
</asp:UpdatePanel>

User Control Code-Behind
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 AZ.SA.RL.App.ProgramManagement.Objects;
using System.ComponentModel;
 
namespace AZ.SA.RL.App.ProgramManagement.Controls
{
    public partial class ReportManager : System.Web.UI.UserControl
    {
        //Enumerators
        #region Enumerators
        public enum QuickReportType
        {
            ByProgrammingCenter = 0,
            ByPrimaryOrganizer = 1,
            ByOutcomes = 2
        }
 
        public enum OpMode
        {
            Quick = 0,
            Custom = 1
        }
 
        public enum DispMode
        {
            Criteria = 0,
            Results = 1
        }
        #endregion
 
        //Properties
        #region Properties
        /// <summary>
        /// Gets or sets the current quick report being run by the manager.
        /// </summary>
        [Browsable(true),
        Category("Function"),
        DefaultValue(QuickReportType.ByProgrammingCenter)]
        public QuickReportType QuickReport
        {
            get
            {
                QuickReportType result = QuickReportType.ByProgrammingCenter;
                if (ViewState["__QUICKREPORT"] != null)
                {
                    result = (QuickReportType)ViewState["__QUICKREPORT"];
                }
 
                return result;
            }
 
            set
            {
                ViewState["__QUICKREPORT"] = value;
            }
        }
         
        /// <summary>
        /// Gets or sets the current operation mode of the manager.
        /// </summary>
        [Browsable(true),
        Category("Function"),
        DefaultValue(OpMode.Quick)]
        public OpMode OperationMode
        {
            get
            {
                OpMode result = OpMode.Quick;
                if (ViewState["__OPERATIONMODE"] != null)
                {
                    result = (OpMode)ViewState["__OPERATIONMODE"];
                }
 
                return result;
            }
 
            set
            {
                ViewState["__OPERATIONMODE"] = value;
            }
        }
 
        /// <summary>
        /// Gets or sets the current display mode of the manager.
        /// </summary>
        [Browsable(true),
        Category("Function"),
        DefaultValue(DispMode.Criteria)]
        public DispMode DisplayMode
        {
            get
            {
                DispMode result = DispMode.Criteria;
                if (ViewState["__DISPLAYMODE"] != null)
                {
                    result = (DispMode)ViewState["__DISPLAYMODE"];
                }
 
                return result;
            }
 
            set
            {
                ViewState["__DISPLAYMODE"] = value;
                //ControlContainer_AjaxPanel.RaisePostBackEvent("__DISPLAYMODECHANGED");
            }
        }
 
        /// <summary>
        /// Sets the title for the manager
        /// </summary>
        [Browsable(true),
        Category("Data"),
        DefaultValue("No Title")]
        public string Title
        {
            private get
            {
                string result = "No Title";
                if (ViewState["__TITLE"] != null)
                {
                    result = (string)ViewState["__TITLE"];
                }
 
                return result;
            }
 
            set
            {
                ViewState["__TITLE"] = value;
            }
        }
 
        /// <summary>
        /// Stores the start datetime for quick report filter
        /// </summary>
        [Browsable(false),
        Category("Data"),
        DefaultValue(null)]
        private DateTime ReportStartDate
        {
            get
            {
                DateTime result = default(DateTime);
                if (ViewState["__STARTDATE"] != null)
                {
                    result = (DateTime)ViewState["__STARTDATE"];
                }
 
                return result;
            }
 
            set
            {
                ViewState["__STARTDATE"] = value;
            }
        }
 
        /// <summary>
        /// Stores the end datetime for quick report filter
        /// </summary>
        [Browsable(false),
        Category("Data"),
        DefaultValue(null)]
        private DateTime ReportEndDate
        {
            get
            {
                DateTime result = default(DateTime);
                if (ViewState["__ENDDATE"] != null)
                {
                    result = (DateTime)ViewState["__ENDDATE"];
                }
 
                return result;
            }
 
            set
            {
                ViewState["__ENDDATE"] = value;
            }
        }
        #endregion
 
        //Methods - Custom
        #region Methods - Custom
        protected void RenderView()
        {
            Label controlHeader = ControlHeader_Label;
            Panel quickReportPanel = QuickReport_Panel;
            Panel customReportPanel = CustomReport_Panel;
            Panel resultPanel = Result_Panel;
 
            switch (DisplayMode)
            {
                case DispMode.Criteria:
                    resultPanel.Visible = false;
 
                    if (OperationMode == OpMode.Quick)
                    {
                        quickReportPanel.Visible = true;
                        customReportPanel.Visible = false;
                    }
                    else if (OperationMode == OpMode.Custom)
                    {
                        quickReportPanel.Visible = false;
                        customReportPanel.Visible = true;
                    }
                    break;
 
                case DispMode.Results:
 
                    if (OperationMode == OpMode.Quick)
                    {
                        resultPanel.Visible = true;
                        quickReportPanel.Visible = false;
                        customReportPanel.Visible = false;
                    }
                    else if (OperationMode == OpMode.Custom)
                    {
 
                    }
                    break;
            }
 
            if (DisplayMode == DispMode.Criteria)
            {
                if (OperationMode == OpMode.Custom)
                {
                    Title = "Custom Report Criteria";
                }
                else
                {
                    Title = "Quick Report Criteria";
                }
            }
 
            //Modify the header to show the current report
            controlHeader.Text = Title;
        }
 
        protected void PopulateQuickReports(object sender)
        
            RadComboBox quickReportList = (RadComboBox)sender;
                         
            foreach (QuickReportType quickReportEnum in Enum.GetValues(typeof(QuickReportType)))
            {
                int value = (int)Enum.Parse(typeof(QuickReportType), quickReportEnum.ToString());
 
                RadComboBoxItem reportItem = new RadComboBoxItem(quickReportEnum.ToString(), value.ToString());
                quickReportList.Items.Add(reportItem);
 
                QuickReportType itemValue = (QuickReportType)value;
 
                switch (itemValue)
                {
                    case QuickReportType.ByProgrammingCenter:
                        reportItem.Text = "By Programming Center";
                        break;
 
                    case QuickReportType.ByPrimaryOrganizer:
                        reportItem.Text = "By Primary Organizer";
                        break;
 
                    case QuickReportType.ByOutcomes:
                        reportItem.Text = "By Primary Goal";
                        break;
                }
            }
        }
 
        protected void RenderReportGrid(object sender, QuickReportType reportType)
        {
            RadGrid reportGrid = (RadGrid)sender;           
            GridBoundColumn boundColumn = null;
 
            reportGrid.MasterTableView.AutoGenerateColumns = false;
            reportGrid.MasterTableView.TableLayout = GridTableLayout.Fixed;
            reportGrid.Columns.Clear();
 
            switch (reportType)
            {
                case QuickReportType.ByProgrammingCenter:
 
                    Title = "Quick Report - Programs by Programming Center (" + ReportStartDate.ToShortDateString() + " - " + ReportEndDate.ToShortDateString() + ")";
                    reportGrid.MasterTableView.ClientDataKeyNames = new string[] { "DepartmentUnitId" };
 
                    if (reportGrid.Columns.Count <= 0)
                    {
                        //Add the Program Name column
                        boundColumn = new GridBoundColumn();
                        reportGrid.Columns.Add(boundColumn);
                        boundColumn.DataField = "UnitName";
                        boundColumn.HeaderText = "Programming Center";
                        boundColumn.UniqueName = "UnitName";
 
                        //Add the Program Name column
                        boundColumn = new GridBoundColumn();
                        reportGrid.Columns.Add(boundColumn);
                        boundColumn.DataField = "UnitShortName";
                        boundColumn.HeaderText = "Unit Short NAme";
                        boundColumn.UniqueName = "UnitShortName";
                        boundColumn.Visible = false;
 
                        //Add the Program Name column
                        boundColumn = new GridBoundColumn();
                        reportGrid.Columns.Add(boundColumn);
                        boundColumn.DataField = "DepartmentUnitId";
                        boundColumn.HeaderText = "DepartmentUnitId";
                        boundColumn.UniqueName = "DepartmentUnitId";
                        boundColumn.Visible = false;
 
                        //Add the Program Count column
                        boundColumn = new GridBoundColumn();
                        reportGrid.Columns.Add(boundColumn);
                        boundColumn.DataField = "ProgramCount";
                        boundColumn.HeaderText = "ProgramCount";
                        boundColumn.UniqueName = "ProgramCount";
                        boundColumn.Visible = false;
                    }
                    break;
 
                case QuickReportType.ByPrimaryOrganizer:
 
                    Title = "Quick Report - Programs by Primary Organizer (" + ReportStartDate.ToShortDateString() + " - " + ReportEndDate.ToShortDateString() + ")";
                    reportGrid.MasterTableView.DataKeyNames = new string[] {"PrimaryOrganizerName","GroupId"};
 
                    if (reportGrid.Columns.Count <= 0)
                    {
                        //Add the Program Name column
                        boundColumn = new GridBoundColumn();
                        reportGrid.Columns.Add(boundColumn);
                        boundColumn.DataField = "PrimaryOrganizerName";
                        boundColumn.HeaderText = "Primary Organizer";
                        boundColumn.UniqueName = "PrimaryOrganizerName";
 
                        //Add the Program Name column
                        boundColumn = new GridBoundColumn();
                        reportGrid.Columns.Add(boundColumn);
                        boundColumn.DataField = "GroupName";
                        boundColumn.HeaderText = "Group Name";
                        boundColumn.UniqueName = "GroupName";
                        boundColumn.Visible = false;
 
                        //Add the Program Name column
                        boundColumn = new GridBoundColumn();
                        reportGrid.Columns.Add(boundColumn);
                        boundColumn.DataField = "GroupId";
                        boundColumn.HeaderText = "GroupId";
                        boundColumn.UniqueName = "GroupId";
                        boundColumn.Visible = false;
 
                        //Add the Program Count column
                        boundColumn = new GridBoundColumn();
                        reportGrid.Columns.Add(boundColumn);
                        boundColumn.DataField = "ProgramCount";
                        boundColumn.HeaderText = "ProgramCount";
                        boundColumn.UniqueName = "ProgramCount";
                        boundColumn.Visible = false;
                    }
                    break;
 
                case QuickReportType.ByOutcomes:
 
                    Title = "Quick Report - Programs by Primary Goal (" + ReportStartDate.ToShortDateString() + " - " + ReportEndDate.ToShortDateString() + ")";
                    reportGrid.MasterTableView.DataKeyNames = new string[] { "BaseOutcomeId" };                   
 
                    if (reportGrid.Columns.Count <= 0)
                    {
                        //Add the Program Name column
                        boundColumn = new GridBoundColumn();
                        reportGrid.Columns.Add(boundColumn);
                        boundColumn.DataField = "PrimaryGoalName";
                        boundColumn.HeaderText = "Primary Goal";
                        boundColumn.UniqueName = "PrimaryGoalName";
 
                        //Add the Base Outcome Id column
                        boundColumn = new GridBoundColumn();
                        reportGrid.Columns.Add(boundColumn);
                        boundColumn.DataField = "BaseOutcomeId";
                        boundColumn.HeaderText = "BaseOutcomeId";
                        boundColumn.UniqueName = "BaseOutcomeId";
                        boundColumn.Visible = false;                       
 
                        //Add the Program Count column
                        boundColumn = new GridBoundColumn();
                        reportGrid.Columns.Add(boundColumn);
                        boundColumn.DataField = "ProgramCount";
                        boundColumn.HeaderText = "ProgramCount";
                        boundColumn.UniqueName = "ProgramCount";
                        boundColumn.Visible = false;
                    }
                    break;
            }
             
            //Set the export file name to the title
            reportGrid.ExportSettings.FileName = Title;
        }
 
        protected void RenderDetailGrid(object sender, QuickReportType reportType)
        {
            //RadGrid reportGrid = (RadGrid)sender;                       
            //GridTableView detailGrid = reportGrid.MasterTableView.DetailTables[0];
 
            GridTableView detailGrid = (GridTableView)sender;           
            GridBoundColumn boundColumn = null;
            GridDateTimeColumn dateColumn = null;
 
            detailGrid.AutoGenerateColumns = false;
            detailGrid.TableLayout = GridTableLayout.Fixed;
 
            switch (reportType)
            {
                case QuickReportType.ByProgrammingCenter:
                     
                     
                    break;
 
                case QuickReportType.ByPrimaryOrganizer:
 
                    if (detailGrid.Columns.Count <= 0)
                    {
                        //Add the Program Name column
                        boundColumn = new GridBoundColumn();
                        detailGrid.Columns.Add(boundColumn);
                        boundColumn.DataField = "ProgramName";
                        boundColumn.HeaderText = "Program Name";
                        boundColumn.UniqueName = "ProgramName";                      
                        //boundColumn.HeaderStyle.Width = Unit.Percentage(30);
                        //boundColumn.ItemStyle.Width = Unit.Percentage(30);
 
                        //Add the Primary Goal column
                        boundColumn = new GridBoundColumn();
                        detailGrid.Columns.Add(boundColumn);
                        boundColumn.DataField = "PrimaryGoalName";
                        boundColumn.HeaderText = "Primary Goal";
                        boundColumn.UniqueName = "PrimaryGoalName";
                        //boundColumn.HeaderStyle.Width = Unit.Percentage(30);
                        //boundColumn.ItemStyle.Width = Unit.Percentage(30);
 
                        //Add the Start Date column                   
                        dateColumn = new GridDateTimeColumn();
                        detailGrid.Columns.Add(dateColumn);
                        dateColumn.DataField = "StartDate";
                        dateColumn.HeaderText = "Start Date";
                        dateColumn.UniqueName = "StartDate";
                        //dateColumn.HeaderStyle.Width = Unit.Percentage(20);
                        //dateColumn.ItemStyle.Width = Unit.Percentage(20);
 
                        //Add the End Date column                   
                        dateColumn = new GridDateTimeColumn();
                        detailGrid.Columns.Add(dateColumn);
                        dateColumn.DataField = "EndDate";
                        dateColumn.HeaderText = "End Date";
                        dateColumn.UniqueName = "EndDate";
                        //dateColumn.HeaderStyle.Width = Unit.Percentage(20);
                        //dateColumn.ItemStyle.Width = Unit.Percentage(20);
                    }
                    break;
                case QuickReportType.ByOutcomes:
 
                    break;
            }
        }
        #endregion
 
        //Methods - Event Handling
        #region Methods - Event Handling                      
        protected void Page_PreRender(object sender, EventArgs e)
        {           
            RadComboBox quickReportList = QuickReportType_Combobox;
 
            if (quickReportList.Items.Count <= 0)
            {
                PopulateQuickReports(quickReportList);
            }
 
            RenderView();
        }
 
        protected void RunReport_Button_Click(object sender, EventArgs e)
        {
            Page.Validate("QuickReportValidation");
 
            if (Page.IsValid)
            {
                RadComboBox quickReportTypeList = QuickReportType_Combobox;
                RadDatePicker startDatePicker = QuickReportStartDate_DatePicker;
                RadDatePicker endDatePicker = QuickReportEndDate_DatePicker;
 
                DateTime startDate = default(DateTime);
                DateTime endDate = default(DateTime);
 
                QuickReportType quickReportType = (QuickReportType)int.Parse(quickReportTypeList.SelectedValue);
 
                if (startDatePicker.SelectedDate.HasValue)
                    startDate = startDatePicker.SelectedDate.Value;
 
                if (endDatePicker.SelectedDate.HasValue)
                    endDate = endDatePicker.SelectedDate.Value;
 
                //Set the quick report type
                QuickReport = quickReportType;
                OperationMode = OpMode.Quick;
                DisplayMode = DispMode.Results;
 
                ReportStartDate = startDate;
                ReportEndDate = endDate;
 
                Result_Grid.Rebind();
            }
        }
 
        protected void Result_Grid_GridExporting(object sender, GridExportingArgs e)
        {
            RadGrid reportGrid = (RadGrid)sender;
 
            switch (e.ExportType)
            {
                case ExportType.Excel:
                    reportGrid.MasterTableView.ExpandCollapseColumn.Visible = false;
                    //reportGrid.MasterTableView.Columns.RemoveAt(0);
                    //reportGrid.MasterTableView.Columns.RemoveAt(0);
                 
                    //reportGrid.MasterTableView.Visible = false;
                    break;
            }
        }
 
        protected void Result_Grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            RadGrid reportGrid = (RadGrid)sender;
             
            if (!e.IsFromDetailTable)
            {
                switch (QuickReport)
                {
                    case QuickReportType.ByProgrammingCenter:
 
                        reportGrid.DataSource = Report.ProgrammingCenters(ReportStartDate, ReportEndDate, true);
                        RenderReportGrid(reportGrid, QuickReport);
                        break;
 
                    case QuickReportType.ByPrimaryOrganizer:
 
                        reportGrid.DataSource = Report.PrimaryOrganinizers(ReportStartDate, ReportEndDate, true);
                        RenderReportGrid(reportGrid, QuickReport);
                        break;
 
                    case QuickReportType.ByOutcomes:
 
                        reportGrid.DataSource = Report.Outcomes(ReportStartDate, ReportEndDate, true);
                        RenderReportGrid(reportGrid, QuickReport);
                        break;
                }               
            }
        }
 
        protected void Result_Grid_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
        {
            RadGrid reportGrid = (RadGrid)sender;
            GridTableView detailGrid = (GridTableView)e.DetailTableView;
 
            //RenderDetailGrid(detailGrid, QuickReport);
 
            GridDataItem dataItem = detailGrid.ParentItem;
 
            switch (QuickReport)
            {
                case QuickReportType.ByProgrammingCenter:
 
                    int departmentUnitId = (int)dataItem.GetDataKeyValue("DepartmentUnitId");
 
                    detailGrid.DataSource = Report.ProgramsByProgrammingCenter(departmentUnitId, ReportStartDate, ReportEndDate);
                    break;
 
                case QuickReportType.ByPrimaryOrganizer:
                                
                    string primaryOrganizerName = dataItem.GetDataKeyValue("PrimaryOrganizerName").ToString();
                    int groupId = (int)dataItem.GetDataKeyValue("GroupId");
 
                    detailGrid.DataSource = Report.ProgramsByPrimaryOrganizer(primaryOrganizerName, groupId, ReportStartDate, ReportEndDate);
                    break;
 
                case QuickReportType.ByOutcomes:
 
                    int baseOutcomeId = (int)dataItem.GetDataKeyValue("BaseOutcomeId");
 
                    detailGrid.DataSource = Report.ProgramsByPrimaryOutcome(baseOutcomeId, ReportStartDate, ReportEndDate);
                    break;
            }           
        }
 
        protected void Result_Grid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                if (e.Item.OwnerTableView.Name == "ReportResults")
                {
                    GridDataItem gridDataItem = (GridDataItem)e.Item;
                    int programCount = 0;
 
                    switch (QuickReport)
                    {
                        case QuickReportType.ByProgrammingCenter:
 
                            string unitName = gridDataItem["UnitName"].Text;
                            programCount = int.Parse(gridDataItem["ProgramCount"].Text);
                             
                            if(programCount == 1)
                                gridDataItem["UnitName"].Text = (unitName + " (" + programCount.ToString() + " Program)").ToUpper();
                            else
                                gridDataItem["UnitName"].Text = (unitName + " (" + programCount.ToString() + " Programs)").ToUpper();
 
                            gridDataItem["UnitName"].Font.Bold = true;
                            gridDataItem["UnitName"].HorizontalAlign = HorizontalAlign.Left;
                            break;
 
                        case QuickReportType.ByPrimaryOrganizer:
                             
                            string organizerName = gridDataItem["PrimaryOrganizerName"].Text.ToString();
                            string groupName = gridDataItem["GroupName"].Text.ToString();
                            programCount = int.Parse(gridDataItem["ProgramCount"].Text);
 
                            if (programCount == 1)
                                gridDataItem["PrimaryOrganizerName"].Text = (groupName + " - " + organizerName + " (" + programCount.ToString() + " Program)").ToUpper();
                            else
                                gridDataItem["PrimaryOrganizerName"].Text = (groupName + " - " + organizerName + " (" + programCount.ToString() + " Programs)").ToUpper();
 
                            gridDataItem["PrimaryOrganizerName"].Font.Bold = true;
                            gridDataItem["PrimaryOrganizerName"].HorizontalAlign = HorizontalAlign.Left;
                            break;
 
                        case QuickReportType.ByOutcomes:
 
                            string outcomeName = gridDataItem["PrimaryGoalName"].Text;
                            programCount = int.Parse(gridDataItem["ProgramCount"].Text);
                             
                            if(programCount == 1)
                                gridDataItem["PrimaryGoalName"].Text = (outcomeName + " (" + programCount.ToString() + " Program)").ToUpper();
                            else
                                gridDataItem["PrimaryGoalName"].Text = (outcomeName + " (" + programCount.ToString() + " Programs)").ToUpper();
 
                            gridDataItem["PrimaryGoalName"].Font.Bold = true;
                            gridDataItem["PrimaryGoalName"].HorizontalAlign = HorizontalAlign.Left;                           
                            break;
                    }                   
                }               
            }
        }
        #endregion
    }
}

Page Code-Behind
using System;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
 
namespace AZ.SA.RL.App.ProgramManagement
{
    public partial class ReportView : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void Report_Toolbar_ButtonClick(object sender, Telerik.Web.UI.RadToolBarEventArgs e)
        {
            //Get clicked button information           
            RadToolBarButton button = (RadToolBarButton)e.Item;
            string command = button.CommandName;
            string value = button.Value;
 
            //Determine which action to take based on the command passed by the clicked toolbar button
            switch (command)
            {
                case "NEW":
 
                    if (value == "Custom")
                    {
                        Report_ReportManager.DisplayMode = ProgramManagement.Controls.ReportManager.DispMode.Criteria;
                        Report_ReportManager.OperationMode = ProgramManagement.Controls.ReportManager.OpMode.Custom;
                    }
                    else
                    {
                        Report_ReportManager.DisplayMode = ProgramManagement.Controls.ReportManager.DispMode.Criteria;
                        Report_ReportManager.OperationMode = ProgramManagement.Controls.ReportManager.OpMode.Quick;
                    }
                    break;
            }
 
            //Update the program content ajax panel
            Content_AjaxPanel.Update();
        }
    }
}

Thanks in advance.
Tsvetina
Telerik team
 answered on 08 Jul 2011
3 answers
65 views
Hi,

I have integrated CKEditor with popup spell checker but when I use more content with tables and list tag, the checker does not scroll well. It does not scroll the content in table if there is any misspell. Please see attachment where popup does not show the "Linux" in textarea but suggest spell for this. This will make user confuse.

Could you please provide any solution for this, I am looking forward for your reply.

Thanks,
Tarun
Tarun
Top achievements
Rank 1
 answered on 08 Jul 2011
3 answers
42 views
Hello folks.

I don't know why, but, when I'm working with telerik radcontrols, I can't see the default icons, like in grid. See my picture below:

http://img90.imageshack.us/img90/8595/noiconsf.png

If you look, the icons of "Add new record" and "Refresh" doesn't appear.

What's wrong? I need to do some more adjusts in my VS?

Regards.
Vasil
Telerik team
 answered on 08 Jul 2011
2 answers
139 views
hi,
I am getting an exception at

 

 

this.pnlprdDes.RenderControl(htmlWriterForPrdtLst); 

that
"Script control 'dgPrd' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
Parameter name: scriptControl"

For this I tried to set the RegisterWithScriptManager property of the RadGrid to "False". Then I did not get any exception, but the control is not going back to a registered java script. Please help me in resolving this issue.

Thanks,
Sudha.

 

Vasil
Telerik team
 answered on 08 Jul 2011
1 answer
57 views
<%@ Page Title="Diagnosis Code Maintanance " Language="C#" MasterPageFile="~/MasterPages/Site.master"
    AutoEventWireup="true" CodeFile="Diagnosis.aspx.cs" Inherits="Codes_Diagnosis"
    EnableTheming="true" Theme="DefaultTheme" %>
 
<%@ Register TagPrefix="MyCtrl" Namespace="CBR.Business" Assembly="CBR.Business" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <script language="javascript" type="text/javascript">
        function clearData() {
            document.getElementById('<%=txtcode.ClientID%>').value = '';
            document.getElementById('<%=txtDescription.ClientID%>').value = '';
            document.getElementById('<%=hdnPK.ClientID%>').value = '';
            document.getElementById('<%=chkUserEntered.ClientID%>').checked = false;
            document.getElementById('<%=chkActive.ClientID%>').checked = false;
            document.getElementById('<%=txtcode.ClientID%>').disabled = false;
            document.getElementById('<%=txtcode.ClientID%>').focus();
            return true;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Skin="Outlook" runat="server" />
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
        <table width="100%" cellpadding="0px" cellspacing="0px" border="0px">
            <tr>
                <td width="100%">
                    <!-- Top Pane Start -->
                    <div class="BillReviewContainer">
                        <div class="PanelTitle">
                            <div class="PanelTitleIcon">
                                Diagnosis</div>
                        </div>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="BillReviewTab">
                            <tr>
                                <td width="15%" align="right">
                                    <asp:Label ID="lblCode" SkinID="Required" runat="server" Text="Code:"></asp:Label>
                                </td>
                                <td width="85%">
                                    <asp:TextBox ID="txtcode" MaxLength="6" SkinID="Small" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="rfvCode" ValidationGroup="Submit" runat="server"
                                        ControlToValidate="txtcode"  SetFocusOnError="true" ErrorMessage="Code is mandatory" Display="None"></asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator ID="revCode" ValidationExpression="(^[+]?\w*\.?\d*[1-9]+\d*$)|(^[+]?[1-9]+\d*\.\d*$)"
                                        runat="server" ValidationGroup="Submit" Display="None" ControlToValidate="txtcode"  SetFocusOnError="true"
                                        ErrorMessage="Only numeric or alphabates are allowed.i.e. e1.23,0.12,121"></asp:RegularExpressionValidator>
                                    <asp:HiddenField ID="hdnPK" runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td align="right" valign="top">
                                    <asp:Label ID="lblDescription" SkinID="Required" runat="server" Text="Description:"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtDescription" TextMode="MultiLine" SkinID="Multiline" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="rfvDesc" ValidationGroup="Submit" runat="server"
                                        ControlToValidate="txtDescription" SetFocusOnError="true" ErrorMessage="Description is mandatory" Display="None"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td valign="middle">
                                    <asp:CheckBox ID="chkUserEntered" runat="server" Text=" User entered" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td valign="middle">
                                    <asp:CheckBox ID="chkActive" runat="server" Text=" Active" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td>
                                    <asp:Button ID="btnSave" OnClick="btnSave_Click" SkinID="InnerSaveButton" ValidationGroup="Submit"
                                        runat="server" />
                                    <asp:Button ID="btnCancel" runat="server" SkinID="InnerClearButton" OnClientClick="return clearData();" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:Label ID="lblMsg" ForeColor="Red" runat="server"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:ValidationSummary ID="vs" HeaderText="Please enter following fields" DisplayMode="BulletList"
                                        runat="server" ValidationGroup="Submit" CssClass="msg" ForeColor="Red" />
                                </td>
                            </tr>
                        </table>
                    </div>
                    <!-- Top Pane Ends -->
                    <!-- Second Pane Start -->
                    <div class="PrevsBillsContainer">
                        <telerik:RadPanelBar ID="RadPanelBar1" runat="server" Width="100%">
                            <Items>
                                <telerik:RadPanelItem Text="Diagnosis" CssClass="PrevsBillsHeader" ImageUrl="~/App_Themes/DefaultTheme/img/previous_bill_icon.png">
                                    <ContentTemplate>
                                        <telerik:RadGrid ID="grdDiagnosis" OnInit="grdDiagnosis_Init" OnItemDataBound="grdDiagnosis_DataBound"
                                            runat="server" AllowAutomaticDeletes="false" OnPreRender="grdDiagnosis_PreRender"
                                            SkinID="ContentGrid" OnItemCommand="grdDiagnosis_ItemCommand">
                                            <MasterTableView TableLayout="Fixed" AllowMultiColumnSorting="true" DataKeyNames="di_int_pk">
                                                <SortExpressions>
                                                    <telerik:GridSortExpression FieldName="di_DiagCode" SortOrder="Ascending" />
                                                </SortExpressions>
                                                <Columns>
                                                    <telerik:GridBoundColumn HeaderText="Diagnosis Code" UniqueName="Code" AutoPostBackOnFilter="true"
                                                        ShowFilterIcon="false" CurrentFilterFunction="StartsWith" DataField="di_DiagCode"
                                                        HeaderStyle-Width="14%" ItemStyle-Width="14%">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn HeaderText="Description" AutoPostBackOnFilter="true" ShowFilterIcon="false"
                                                        UniqueName="Description" CurrentFilterFunction="StartsWith" DataField="di_DiagDescription">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridCheckBoxColumn DataField="di_User" FilterListOptions="VaryByDataType"
                                                        HeaderText="User entered" CurrentFilterFunction="NoFilter" UniqueName="Userentered"
                                                        HeaderStyle-Width="10%" ItemStyle-Width="10%">
                                                    </telerik:GridCheckBoxColumn>
                                                    <telerik:GridCheckBoxColumn DataField="di_Active" FilterListOptions="VaryByDataType"
                                                        HeaderText="Active" CurrentFilterFunction="NoFilter" UniqueName="Active" HeaderStyle-Width="6%"
                                                        ItemStyle-Width="6%"  Resizable="false">
                                                    </telerik:GridCheckBoxColumn>
                                                    <telerik:GridTemplateColumn AllowFiltering="false" HeaderStyle-Width="40px" ItemStyle-Width="40px"  Resizable="false">
                                                        <ItemStyle HorizontalAlign="Center" />
                                                        <ItemTemplate>
                                                            <%-- <asp:LinkButton ID="LinkButton1" runat="server" Text="Edit" CommandName="Show"></asp:LinkButton>--%>
                                                            <asp:ImageButton ID="ImgEdit" runat="server" AlternateText="Edit" CommandName="Show"
                                                                ImageUrl="~/Images/edit_icon.png" />
                                                            <asp:HiddenField ID="hdnID" runat="server" Value='<%# Eval("di_int_pk") %>' />
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridButtonColumn ConfirmText="Do you want to delete this entry?" ConfirmDialogType="RadWindow"
                                                        ConfirmTitle="Delete" CommandName="Delete" Text="Delete" ButtonType="ImageButton"
                                                        ImageUrl="~/Images/delete_icon.png" UniqueName="DeleteColumn" HeaderStyle-Width="40px"
                                                        ItemStyle-Width="40px" Resizable="false">
                                                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                                                    </telerik:GridButtonColumn>
                                                </Columns>
                                            </MasterTableView>
                                        </telerik:RadGrid>
                                    </ContentTemplate>
                                </telerik:RadPanelItem>
                            </Items>
                            <CollapseAnimation Duration="100" Type="None" />
                            <ExpandAnimation Duration="100" Type="None" />
                        </telerik:RadPanelBar>
                    </div>
                    <!-- Second Pane Ends -->
                </td>
            </tr>
        </table>
    </telerik:RadAjaxPanel>
</asp:Content>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Collections;
using System.Web.UI.WebControls;
using CBR.Business;
using CBR.DataModel;
using System.Data;
using Telerik.Web.UI;

public partial class Codes_Diagnosis : System.Web.UI.Page
{

    #region Page Events

    /// <summary>
    /// Page Load event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            txtcode.Focus();
            Bind();
            if (RadPanelBar1.Items.Count > 0)
                RadPanelBar1.Items[0].Expanded = true;
        }
    }

    #endregion

    #region Functions

    /// <summary>
    /// Bind grid
    /// </summary>
    private void Bind()
    {
        List<Diagnostic> objDiagnostic = CodesManager.GetAllDiagnosis();
        //grdDiagnosis.VirtualItemCount = objServices.Count;
        grdDiagnosis.DataSource = objDiagnostic;
        grdDiagnosis.DataBind();

    }

    /// <summary>
    /// Clear all fields
    /// </summary>
    private void ClearAll()
    {
        txtcode.Text = "";
        txtDescription.Text = "";
        chkUserEntered.Checked = false;
        chkActive.Checked = false;
        txtcode.Enabled = true;
        txtcode.Focus();
    }

    #endregion

    #region Grid events

    /// <summary>
    /// Grid Prerender event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void grdDiagnosis_PreRender(object sender, System.EventArgs e)
    {
        Bind();
    }

    /// <summary>
    /// Actions to perform for different commands
    /// </summary>
    /// <param name="source"></param>
    /// <param name="e"></param>
    protected void grdDiagnosis_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked
        {

        }
        else if (e.CommandName == RadGrid.DeleteCommandName)
        {
            lblMsg.Text = "";
            GridDataItem editedItem = (GridDataItem)e.Item;
            int ID = Convert.ToInt32(((HiddenField)editedItem.FindControl("hdnID")).Value);
            CodesManager.DeleteDiagnosticByID(ID);
            ClearAll();
            Bind();
        }

        else if (e.CommandName == "Show")
        {
            lblMsg.Text = "";
            GridDataItem selectedItem = (GridDataItem)e.Item;
            Hashtable selectedItemValues = new Hashtable();
            selectedItem.ExtractValues(selectedItemValues);
            if (!Convert.ToBoolean(selectedItemValues["di_User"]))
            {
                txtcode.Enabled = false;
                txtDescription.Focus();
            }
            else
            {
                txtcode.Focus();
            }
            txtcode.Text = selectedItemValues["di_DiagCode"].ToString().Trim();
            txtDescription.Text = selectedItemValues["di_DiagDescription"].ToString().Trim();
            chkUserEntered.Checked = Convert.ToBoolean(selectedItemValues["di_User"]);
            chkActive.Checked = Convert.ToBoolean(selectedItemValues["di_Active"]);
            hdnPK.Value = ((HiddenField)selectedItem.FindControl("hdnID")).Value;

        }
    }

    /// <summary>
    /// Hide Top command row
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void grdDiagnosis_DataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridCommandItem)
        {
            GridCommandItem cmditm = (GridCommandItem)e.Item;
            cmditm.FindControl("RefreshButton").Visible = false;//hide the text
            cmditm.FindControl("RebindGridButton").Visible = false;//hide the image
            e.Item.FindControl("InitInsertButton").Visible = false;//hide Add text
            e.Item.FindControl("AddNewRecordButton").Visible = false;//hide add button
            e.Item.Visible = false; // hide Top command row
        }
    }

    /// <summary>
    /// Init event to hide filter options from checkbox field filter
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void grdDiagnosis_Init(object sender, System.EventArgs e)
    {
        GridFilterMenu menu = grdDiagnosis.FilterMenu;
        int i = 0;

        while (i < menu.Items.Count)
        {
            if (menu.Items[i].Text == "NoFilter" || menu.Items[i].Text == "EqualTo")
            {
                i++;
            }
            else
            {
                menu.Items.RemoveAt(i);
            }
        }

    }

    #endregion

    # region Events

    protected void btnSave_Click(object sender, EventArgs e)
    {
        Diagnostic objDiagnostic = new Diagnostic();
        objDiagnostic.di_DiagCode = txtcode.Text;
        objDiagnostic.di_DiagDescription = txtDescription.Text;
        objDiagnostic.di_User = chkUserEntered.Checked;
        objDiagnostic.di_Active = chkActive.Checked;
        lblMsg.Text = "";
        if (hdnPK.Value == "")
        { // Insert
            if (CodesManager.GetDiagnosisByCode(txtcode.Text).Count > 0)
            {

                lblMsg.Text = "Diagnosis Code already exists";
                return;
            }
            else
            {
                objDiagnostic.di_Type = "";
                objDiagnostic.di_MajorDiagGrouping = "";
                objDiagnostic.di_Catastrophic = false;
                CodesManager.InsertDiagnostic(objDiagnostic);
                lblMsg.Text = "Diagnosis Code added successfully";
                txtcode.Enabled = true;
            }
        }
        else
        // Update
        {
            objDiagnostic.di_int_pk = Convert.ToInt32(hdnPK.Value);
            CodesManager.UpdateDiagnostic(objDiagnostic);
            //btnSave.Text = "Insert";
        }
        hdnPK.Value = "";
        ClearAll();
    }

    protected void btnCancel_Click(object sender, EventArgs e)
    {
        hdnPK.Value = "";
        ClearAll();
        lblMsg.Text = "";

    }

    #endregion

}


#region Diagnosis
        public static List<Diagnostic> GetAllDiagnosis()
        {


            List<Diagnostic> objDiagnostic = new List<Diagnostic>();

            try
            {
                objDiagnostic = CodesData.GetAllDiagnosis();
            }
            catch (Exception ex)
            {
                LogManager.GetLogger("Business-CodesManager-GetAllDiagnosis").Error(ex);
                throw ex;
            }

            return objDiagnostic;
        }

        public static List<Diagnostic> GetDiagnosisByCode(string Code)
        {
            List<Diagnostic> objDiagnostic = new List<Diagnostic>();

            try
            {
                objDiagnostic = CodesData.GetDiagnosisByCode(Code);
            }
            catch (Exception ex)
            {
                LogManager.GetLogger("Business-CodesManager-GetDiagnosisByCode").Error(ex);
                throw ex;
            }

            return objDiagnostic;
        }

        public static void InsertDiagnostic(Diagnostic objDiagnostic)
        {
            try
            {
                CodesData.AddDiagnosis(objDiagnostic);
            }
            catch (Exception ex)
            {
                LogManager.GetLogger("Business-CodesManager-InsertDiagnostic").Error(ex);
                throw ex;
            }
        }

        public static void UpdateDiagnostic(Diagnostic objDiagnostic)
        {
            try
            {
                CodesData.UpdateDiagnosisByID(objDiagnostic);
            }
            catch (Exception ex)
            {
                LogManager.GetLogger("Business-CodesManager-UpdateDiagnostic").Error(ex);
                throw ex;
            }
        }

        public static void DeleteDiagnosticByID(Int32 ID)
        {
            try
            {
                CodesData.DeleteDiagnosisByID(ID);
            }
            catch (Exception ex)
            {
                LogManager.GetLogger("Business-CodesManager-DeleteDiagnosticByID").Error(ex);
                throw ex;
            }
        }

        #endregion


 public static Diagnostic AddDiagnosis(Diagnostic objDiagnosis)
        {
            using (CBREntities CBRContext = new CBREntities())
            {
                CBRContext.Connection.Open();
                DbTransaction objTrans = CBRContext.Connection.BeginTransaction();

                try
                {

                    CBRContext.AddToDiagnostics(objDiagnosis);
                    CBRContext.SaveChanges();
                    objTrans.Commit();

                }
                catch (Exception ex)
                {
                    LogManager.GetLogger("DataAccess-CodesDAL-AddDiagnosis").Error(ex);
                    objTrans.Rollback();
                    throw ex;
                }
            }
            return objDiagnosis;
        }

        public static List<Diagnostic> GetDiagnosisByCode(string Code)
        {
            using (CBREntities CBRContext = new CBREntities())
            {
                CBRContext.Connection.Open();
                DbTransaction objTrans = CBRContext.Connection.BeginTransaction();
                try
                {
                    List<Diagnostic> resultList =
                    (from ServieList in CBRContext.Diagnostics
                     where ServieList.di_DiagCode == Code
                     select ServieList).ToList();
                    objTrans.Commit();
                    return resultList;

                }
                catch (Exception ex)
                {
                    objTrans.Rollback();
                    LogManager.GetLogger("DataAccess-CodesDAL-GetDiagnosisByCode").Error(ex);
                    throw ex;
                }

            }
        }

        public static List<Diagnostic> GetAllDiagnosis()
        {
            CBREntities objCBREntities = new CBREntities();
            objCBREntities.Connection.Open();
            List<Diagnostic> objStateInfo = new List<Diagnostic>();
            DbTransaction objTrans = objCBREntities.Connection.BeginTransaction();

            try
            {
                objStateInfo = objCBREntities.Diagnostics.Select(row => row).ToList();
                objTrans.Commit();

            }
            catch (Exception ex)
            {
                LogManager.GetLogger("DataAccess-CodesDAL-GetAllDiagnosis").Error(ex);
                objTrans.Rollback();
                throw ex;
            }

            return objStateInfo;
        }

        public static void UpdateDiagnosis(Diagnostic objDiagnosis)
        {
            EntityKey key = null;
            object original = null;

            using (CBREntities CBRContext = new CBREntities())
            {
                CBRContext.Connection.Open();
                DbTransaction objTrans = CBRContext.Connection.BeginTransaction();

                try
                {
                    key = CBRContext.CreateEntityKey("Diagnostics", objDiagnosis);
                    if (CBRContext.TryGetObjectByKey(key, out original))
                    {
                        CBRContext.ApplyCurrentValues(key.EntitySetName, objDiagnosis);
                    }
                    CBRContext.SaveChanges();
                    objTrans.Commit();

                }
                catch (Exception ex)
                {

                    objTrans.Rollback();
                    LogManager.GetLogger("DataAccess-CodesDAL-UpdateDiagnosis").Error(ex);
                    throw ex;
                }
            }
        }

        public static void UpdateDiagnosisByID(Diagnostic objDiagnosis)
        {
            using (CBREntities CBRContext = new CBREntities())
            {
                CBRContext.Connection.Open();
                DbTransaction objTrans = CBRContext.Connection.BeginTransaction();

                Diagnostic resultList =
                    (from ServieList in CBRContext.Diagnostics
                     where ServieList.di_int_pk == objDiagnosis.di_int_pk
                     select ServieList).FirstOrDefault();
                resultList.di_DiagCode = objDiagnosis.di_DiagCode;
                resultList.di_DiagDescription = objDiagnosis.di_DiagDescription;
                resultList.di_Active = objDiagnosis.di_Active;
                resultList.di_User = objDiagnosis.di_User;
                try
                {
                    CBRContext.SaveChanges();
                    objTrans.Commit();

                }
                catch (Exception ex)
                {
                    objTrans.Rollback();

                    LogManager.GetLogger("DataAccess-CodesDAL-UpdateDiagnosisByID").Error(ex);
                    throw ex;
                }
            }

        }

        public static void DeleteDiagnosisByID(Int32 ID)
        {
            using (CBREntities CBRContext = new CBREntities())
            {
                CBRContext.Connection.Open();
                DbTransaction objTrans = CBRContext.Connection.BeginTransaction();

                Diagnostic resultList =
                    (from UserList in CBRContext.Diagnostics
                     where UserList.di_int_pk == ID
                     select UserList).FirstOrDefault();

                CBRContext.DeleteObject(resultList);

                try
                {
                    CBRContext.SaveChanges();
                    objTrans.Commit();

                }
                catch (Exception ex)
                {
                    objTrans.Rollback();

                    LogManager.GetLogger("DataAccess-CodesDAL-DeleteDiagnosisByID").Error(ex);
                    throw ex;
                }
            }
        }

        #endregion
Bhanu
Top achievements
Rank 1
 answered on 08 Jul 2011
7 answers
227 views
Hi,

We have two extremly important requirements as below :

1.   To show the count of appointments in monthly view. Is there some way that we can customize the text in 'more' link to show the count of appointments (like in google calendars they show the count of appointments for that day) ?

2. We need to add another 'Agenda' view like in google calendars. How to do that seamlessly with consistent look and feel as existing views ?

Would really appreciate if we could have answers to the above asap.
Also, for both the above would it be a feasible option to extend the source code and use the control once we buy the licencsed version of the product and have access to the code ?

Thanks,
Sandeep
Peter
Telerik team
 answered on 08 Jul 2011
1 answer
81 views
I found this tip in another forum post:
----------------------
      http://www.telerik.com/community/forums/aspnet/window/forms-authentication.aspx#454784

     >If I understand you correctly you wish to redirect the parent page to your login one once the session expires. If this
      is the case, our suggestion is to add the following code to your Login page

      if (window != window.top) window.top.navigate(window.location.href); (IE only)
       OR
      if (window != window.top) window.top.location.href = window.location.href; (cross-browser)

    This code makes sure that the Login page loads in the top browser window, even if it is initially loaded in one of the
     RadWindow  objects.
----------------------

I do a reasonable amount of Javascript coding here and there, but nothing with window management. Into what event would I insert this code snip? Could you give a more complete code sample?

Thanks.
Marin Bratanov
Telerik team
 answered on 08 Jul 2011
1 answer
57 views
Hi all,

I have a Email column which uses "telerik:GridTemplateColumn".
Normally, my customer often copies email from existed emails when create a new record.
But when copy & paste, it includes the space at the end which causes error because of email validation.
This one doesn't happen with telerik:GridBoundColumn".
I mean there is no space at the end when highlight if use telerik:GridBoundColumn
Are there any ways to fix it?

Thanks.

Andy.
Tsvetina
Telerik team
 answered on 08 Jul 2011
2 answers
85 views
We have a Click Event that calls

RadAjaxManager1.ResponseScripts.Add(

"btnBankingAlertClick()");

This opens a radwindow as below

function

btnBankingAlertClick() {

var oWnd = radopen("Dialogs/Alert.aspx?ftn=6", "GenericDialogWindow");

}

 

In ClientClose we pick up the argument and call

 

if(arg.res) AjaxPostback('EndCollection:');

In RadAjaxManager_AjaxRequest a method is called and as part of that the following lines are called
 

RadAjaxManager1.Alert("Collection information inserted into banking sucessfully");

RadAjaxManager1.ResponseScripts.Add("btnBankingAlertDoneClick()");

 

When debugging i can see ths code is hit but the alert and the function are not called.

Please help!!

Darren Nicholl
Top achievements
Rank 1
 answered on 08 Jul 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?