Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi I have this implementation of devexpress grid view with
DataSourceForceStandardPaging="true"
.

This grid taking a lot of time.
The stored procedure time is just 1 sec max. but still this grid takes 15 to 22 sec only for 10 records.

As i see on loading or page change this devexpress call server multiple time.

Can some one please rectify the problem what i am doing....


Thanks a lot to every one in advance...

This is my full code....



This is my BaseGrid class:

C#
using System;
using System.Collections.Generic;
using DevExpress.Web.ASPxGridView;
using DevExpress.Web.ASPxGridView.Export;
using System.Web.UI;
using TTX.Application.PipelineManagement.BLL;
using DevExpress.XtraPrinting;
using DevExpress.Utils;
using TTX.Application.PipelineManagement.Common;
using TTX.Application.PipelineManagement.Entities;

namespace TTX.Application.PipelineManagement.UI.UserControls
{
    public abstract class ResultGridView<T> : UserControl
    {
        #region Constants

        public const string EventArgs = "__EVENTARGUMENT";
        public const string PagerOnClickText = "PAGERONCLICK";
        public const string PSPText = "PSP";
        public const char PipeSeperator = '|';

        #endregion

        #region Properties
        public IEnumerable<T> Data
        { get; set; }


        public IList<T> TicketsData
        { get; set; }

        public string PageName
        {
            get;
            private set;
        }

        public string FilterSessionName
        {
            get;
            private set;
        }

        public ASPxGridView GridView
        {
            get;
            protected set;
        }

        public ASPxGridViewExporter GridViewExporter
        {
            get;
            protected set;
        }
        #endregion

        #region Constructor

        public ResultGridView(string pageName, string filterSessionName)
        {
            Data = null;
            PageName = pageName;
            FilterSessionName = filterSessionName;
        }

        #endregion

        #region Page Specific Events


        /// <summary>
        /// Handles the Init event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks></remarks>
        protected virtual void Page_Init(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.QueryString[UIConstants.Preference] != null)
                {
                    if (PageName.Equals(UIConstants.Url.AdvancedView))
                    {
                        AdvancedFilterDTO filterEntity = new UserPreferencesBL().GetUserPreference<AdvancedFilterDTO>(Context.User.Identity.Name, UIConstants.ApplicationName, Request.QueryString[UIConstants.Preference], PageName);
                        if (filterEntity != null)
                        {
                            Session[FilterSessionName] = filterEntity;
                        }
                    }
                    else
                    {
                        FilterBaseDTO filterEntity = new UserPreferencesBL().GetUserPreference<FilterBaseDTO>(Context.User.Identity.Name, UIConstants.ApplicationName, Request.QueryString[UIConstants.Preference], PageName);
                        if (filterEntity != null)
                        {
                            Session[FilterSessionName] = filterEntity;
                        }
                    }
                }
            }
        }

        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks></remarks>
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                PageSizeChangedHandler();
            }

        }
        #endregion

        #region Events
        public virtual void GridViewExporter_RenderBrick(object sender, ASPxGridViewExportRenderingEventArgs e)
        {
            //Align to top-left while exporting to Excel and Pdf
            e.BrickStyle.TextAlignment = TextAlignment.TopLeft;
            e.BrickStyle.SetAlignment(HorzAlignment.Near, VertAlignment.Top);
        }
        #endregion

        #region Abstract  Methods

        /// <summary>
        /// Get Ticket Information from session.
        /// </summary>
        /// <param name="sortBy"></param>
        /// <param name="pageSize"></param>
        /// <param name="startIndex"></param>
        /// <returns></returns>
        public abstract IEnumerable<T> GetSourceData(string sortBy, int pageSize, int startIndex);






        #endregion

        #region Public Methods

        /// <summary>
        /// Method To Bind Grid
        /// </summary>
        public virtual void BindDataGrid()
        {
            GridView.DataBind();
        }

        /// <summary>
        /// Export the Grid Data to PDF format
        /// </summary>
        /// <remarks></remarks>
        public virtual void ExportGridDataToPDF()
        {
            BindDataForExport();
            GridViewExporter.FileName = UIConstants.Gridviews.TDPDFFileName;
            GridViewExporter.Landscape = true;
            GridViewExporter.WritePdfToResponse();
        }

        /// <summary>
        /// Funtionality to Export the Grid to Excel Format
        /// </summary>
        /// <remarks></remarks>
        public virtual void ExportGridDataToExcel()
        {
            BindDataForExport();
            GridViewExporter.FileName = UIConstants.Gridviews.TDExcelFileName;
            GridViewExporter.WriteXlsToResponse();
        }

        #endregion

        #region Protected Methods

        /// <summary>
        /// Method to Bind Data For Export
        /// </summary>
        protected virtual void BindDataForExport()
        {
            BindDataGrid();
        }

        /// <summary>
        /// Function to calculate total number of tickets in the Ticket Grid View
        /// </summary>
        protected virtual void SetPagerAndItemCount()
        {
            int pageSize = GridView.SettingsPager.PageSize;
            string[] pageSizeItems = GridView.SettingsPager.PageSizeItemSettings.Items;
            bool isPageSizeAll = true;
            foreach (string value in pageSizeItems)
            {
                if (value.Equals(pageSize.ToString()))
                {
                    isPageSizeAll = false;
                    break;
                }
            }
            //Check the page count on each filter
            if (GridView.PageCount > 0)
            {
                int itemCount = Context.Session[UIConstants.Sessions.TicketsCountSession] != null ? Convert.ToInt32(Context.Session[UIConstants.Sessions.TicketsCountSession]) : (int)GridView.GetTotalSummaryValue(GridView.TotalSummary[UIConstants.TicketData.FieldName.TicketId]);
                if (!isPageSizeAll)
                {
                    GridView.SettingsPager.Summary.Text = string.Concat(UIConstants.UIControls.GridViewPagerTextPrefix, itemCount.ToString(), UIConstants.UIControls.GridViewPagerTextSuffix);
                }
                else
                {
                    GridView.SettingsPager.Summary.AllPagesText = string.Concat(UIConstants.UIControls.GridViewPagerTextPrefix, itemCount.ToString(), UIConstants.UIControls.GridViewPagerTextSuffix);
                }
                GridView.SettingsPager.PageSizeItemSettings.Visible = true;
            }
        }

        /// <summary>
        /// Handle the change of page size drop down.
        /// </summary>
        protected virtual void PageSizeChangedHandler()
        {
            int pageSize = GetPageSizeFromPostbackData();

            if (pageSize != 0)
            {
                SetPageSize(pageSize);
            }
        }

        /// <summary>
        /// Set the page size for All (-1) and other selections
        /// </summary>
        /// <param name="pageSize"></param>
        protected virtual void SetPageSize(int pageSize)
        {
            if (pageSize == -1)
            {
                GridView.SettingsPager.PageSize = GridView.VisibleRowCount;
                GridView.PageIndex = -1;
            }
            else
            {
                GridView.SettingsPager.PageSize = pageSize;
            }
        }

        /// <summary>
        /// Get the page size from postback event arguments
        /// </summary>
        /// <returns>page size</returns>
        protected virtual int GetPageSizeFromPostbackData()
        {
            int pageSize = 0;
            var eventArgs = Request.Form[EventArgs];
            if (!(string.IsNullOrEmpty(eventArgs)))
            {
                var args = eventArgs.Split(new char[] { PipeSeperator });
                if (args.Length >= 2)
                {
                    if (args[1].StartsWith(PagerOnClickText))
                    {
                        int.TryParse(args[2].Replace(PSPText, string.Empty), out pageSize);
                    }
                }
            }
            return pageSize;
        }

        #endregion

    }
}


This is my custome grid control:

ASCX File:
XML
<pre lang="xml">
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PipelineGridControl.ascx.cs"
    Inherits="TTX.Application.PipelineManagement.UI.UserControls.PipelineGridControl" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v12.1.Export, Version=12.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dxre" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v12.1, Version=12.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v12.1, Version=12.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Src="~/UserControls/TicketEditPopUp.ascx" TagName="Edit" TagPrefix="Uc" %>
<%@ Import Namespace="TTX.Application.PipelineManagement.Common" %>
<%@ Register TagPrefix="dx" Namespace="DevExpress.Web.ASPxEditors" Assembly="DevExpress.Web.ASPxEditors.v12.1" %>
<%@ Register TagPrefix="dx" Namespace="DevExpress.Web.ASPxGridView" Assembly="DevExpress.Web.ASPxGridView.v12.1" %>
<script src="../Scripts/EditPopup.js" type="text/javascript"></script>
<style type="text/css">
    .dxgvTable {
        border-collapse: separate !important;
        color: Black;
    }
</style>
<script type="text/javascript">
    function OnInit(s, e) {
        AdjustGridSize();

    }
    function OnEndCallback(s, e) {
        AdjustGridSize();
    }

</script>
<%-- Addint Edit Control --%>
<Uc:Edit ID="ucEdit" runat="server" />
<asp:UpdatePanel ID="pannel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <dxwgv:ASPxGridView ID="ticketGridView" runat="server" AutoGenerateColumns="False" ClientInstanceName="tcktGridView" Width="100%" EnableViewState="True"
            DataSourceID="ticketDataSource" KeyFieldName="TicketId" SkinID="aspxGridViewSkin" EnableCallBacks="true" OnPreRender="ticketGridView_PreRender" EnableRowsCache="false"
            OnHtmlDataCellPrepared="ticketGridView_OnHtmlDataCellPrepared" Styles-EmptyDataRow-HorizontalAlign="Left" OnCustomColumnSort="ticketGridView_CustomColumnSort" DataSourceForceStandardPaging="true">
            <ClientSideEvents Init="OnInit" EndCallback="OnEndCallback" />
            <SettingsBehavior ColumnResizeMode="Control" />

              <SettingsPager Mode="ShowPager" AlwaysShowPager="True" Position="Bottom"  ShowDisabledButtons="true" ShowSeparators="true" >
                  <PageSizeItemSettings Position="Right" ShowAllItem="True" Items="10, 50">
                </PageSizeItemSettings>
                        <FirstPageButton Visible="True">
                        </FirstPageButton>
                        <LastPageButton Visible="True">
                        </LastPageButton>
              </SettingsPager>
            <Settings ShowGroupPanel="True" ShowHorizontalScrollBar="true" ShowStatusBar="Hidden" ShowVerticalScrollBar="true" />
            <GroupSummary>
                <dxwgv:ASPxSummaryItem FieldName="TicketId" SummaryType="Count" />
            </GroupSummary>
            <TotalSummary>
                <dxwgv:ASPxSummaryItem FieldName="TicketId" SummaryType="Count" ShowInColumn="TicketId"
                    DisplayFormat="{0} Items" />
            </TotalSummary>
            <SettingsCustomizationWindow Enabled="True" PopupHorizontalAlign="LeftSides" PopupVerticalAlign="TopSides" />
            <Styles>
                <Header Wrap="True" HorizontalAlign="Center" VerticalAlign="Middle">
                    <Paddings Padding="5px" />
                </Header>
                <GroupPanel HorizontalAlign="Center" VerticalAlign="Middle">
                </GroupPanel>
                <Cell HorizontalAlign="Left" VerticalAlign="Top"></Cell>
            </Styles>
            <Columns>
                <dxwgv:GridViewDataColumn VisibleIndex="0" FieldName="TicketId" Caption="Ticket #" Width="75px" ToolTip="Ticket #" CellStyle-HorizontalAlign="Left"
                    SortIndex="0" SortOrder="Descending" Settings-SortMode="Custom">
                    <DataItemTemplate>
                        <asp:HyperLink ID="scsmUrl" runat="server" NavigateUrl='<%# System.Configuration.ConfigurationManager.AppSettings["ScsmUrl"] + Eval("RequestId") %>'
                            Target="_blank" Text='<%#Eval("TicketId") %>' ForeColor="DarkCyan" />
                    </DataItemTemplate>
                </dxwgv:GridViewDataColumn>
                <dxwgv:GridViewDataTextColumn VisibleIndex="1" FieldName="ShortDescription" Caption="Description" ToolTip="Description" Width="150px" />
                <dx:GridViewDataDateColumn VisibleIndex="2" FieldName="CreatedDate" Caption="Created Date" ToolTip="Created Date" Width="80px">
                    <PropertiesDateEdit DisplayFormatString="M/d/yyyy">
                    </PropertiesDateEdit>
                </dx:GridViewDataDateColumn>
                <dx:GridViewDataDateColumn VisibleIndex="3" FieldName="ResolvedDate" Caption="Resolved Date" ToolTip="Resolved Date" Width="80px">
                    <PropertiesDateEdit DisplayFormatString="M/d/yyyy">
                    </PropertiesDateEdit>
                </dx:GridViewDataDateColumn>
                <dx:GridViewDataDateColumn VisibleIndex="4" FieldName="PlannedStartDate" Caption="Planned Start Date" ToolTip="Planned Start Date" Width="80px">
                    <PropertiesDateEdit DisplayFormatString="M/d/yyyy">
                    </PropertiesDateEdit>
                </dx:GridViewDataDateColumn>
                <dx:GridViewDataDateColumn VisibleIndex="5" FieldName="PlannedEndDate" Caption="Planned End Date" ToolTip="Planned End Date" Width="80px">
                    <PropertiesDateEdit DisplayFormatString="M/d/yyyy">
                    </PropertiesDateEdit>
                </dx:GridViewDataDateColumn>
                <dxwgv:GridViewDataTextColumn VisibleIndex="6" FieldName="Status" Caption="Status" ToolTip="Status" Width="80px" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="7" FieldName="RankingNumber" Caption="Ranking Number" ToolTip="Ranking Number" Width="80px" CellStyle-Wrap="True" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="8" FieldName="LOB" Caption="LOB/ Business Area" ToolTip="LOB/ Business Area" Width="65px" CellStyle-Wrap="True" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="9" FieldName="Icfr" Caption="ICFR" ToolTip="ICFR" Width="50px" Settings-GroupInterval="DisplayText" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="10" FieldName="RequestorText" Caption="Requestor" ToolTip="Requestor" />
                <dxwgv:GridViewDataDateColumn VisibleIndex="11" FieldName="OwnerName" Caption="Owner Name" ToolTip="Owner Name" Settings-GroupInterval="DisplayText" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="12" FieldName="TicketType.TicketType" Caption="Ticket Type" ToolTip="Ticket Type" Width="60px" Settings-GroupInterval="DisplayText" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="13" FieldName="ApplicationName" Caption="Application/ Module" ToolTip="Application/ Module" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="14" FieldName="HighLevelEstimate.HighLevelEstimateValue" Caption="High Level Estimate" ToolTip="High Level Estimate" Width="85px" />
                <dxwgv:GridViewDataDateColumn VisibleIndex="15" FieldName="Que" Caption="Queue" ToolTip="Queue" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="16" FieldName="PlannedRelease" Caption="Planned Release" ToolTip="Planned Release" Width="75px" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="17" FieldName="ReleaseRanking" Caption="Release Ranking" ToolTip="Release Ranking" Width="80px" CellStyle-Wrap="True" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="18" FieldName="ProposedRelease" Caption="Proposed Release" ToolTip="Proposed Release" Width="75px" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="19" FieldName="ShortReleaseNotes" Caption="User/Release Notes" Name="User/ReleaseNotes" ToolTip="User/Release Notes" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="20" FieldName="ShortNotes" Caption="IT Notes" Name="Notes" ToolTip="IT Notes" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="21" FieldName="ShortRankingNotes" Caption="Ranking Notes" Name="RankingNotes" ToolTip="Ranking Notes" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="22" FieldName="ITContact" Caption="IT Contact" ToolTip="IT Contact" Width="60px" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="23" FieldName="Tester" Caption="Tester" ToolTip="Tester" Width="60px" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="24" FieldName="Priority.Priority" Caption="Priority" ToolTip="Priority" Width="75px" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="25" FieldName="BRM" Caption="BRM" ToolTip="BRM" Width="60px" />
                <dxwgv:GridViewDataTextColumn VisibleIndex="26" FieldName="DevelopmentEffort" Caption="Est. Dev Effort" ToolTip="Estimated Development Effort" Width="75px" />
                <dxwgv:GridViewDataTextColumn FieldName="ReleaseStatus.Color" Visible="false" Caption="Release Status" ToolTip="Release Status" Settings-GroupInterval="DisplayText" />
                <dxwgv:GridViewDataTextColumn FieldName="ReleaseCommitment.Color" Visible="false" Caption="Release Commitment" ToolTip="Release Commitment" Settings-GroupInterval="DisplayText" />
            </Columns>
        </dxwgv:ASPxGridView>


        <asp:ObjectDataSource ID="ticketDataSource" EnablePaging="true" runat="server"  SortParameterName = "sortBy" StartRowIndexParameterName="startIndex" MaximumRowsParameterName="pageSize" SelectMethod="GetSourceData" SelectCountMethod ="GetSourceDataCount"
        TypeName="TTX.Application.PipelineManagement.UI.UserControls.PipelineGridControl">
        </asp:ObjectDataSource>




        <%-- Functionality For export to PDF and Excel--%>
        <dxre:ASPxGridViewExporter ID="ticketGridViewExporter" runat="server" GridViewID="ticketGridView" OnRenderBrick="GridViewExporter_RenderBrick"
            BottomMargin="0" Landscape="True" LeftMargin="0" RightMargin="0" TopMargin="0">
            <Styles>
                <Header BackColor="#6C4D23" Font-Names="Verdana" Font-Size="8pt" ForeColor="White"
                    Paddings-PaddingLeft="2px" Paddings-PaddingRight="4px" Paddings-PaddingTop="6px"
                    Paddings-PaddingBottom="7px">
                </Header>
                <Cell Font-Names="Verdana" Font-Size="8pt" />
            </Styles>
        </dxre:ASPxGridViewExporter>
    </ContentTemplate>
</asp:UpdatePanel>


THIS IS MY CUSTOM CONTROL ASCX.CS FIle:

C#
using DevExpress.Web.ASPxGridView;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using TTX.Application.PipelineManagement.BLL;
using TTX.Application.PipelineManagement.Common;
using TTX.Application.PipelineManagement.Entities;

namespace TTX.Application.PipelineManagement.UI.UserControls
{
    /// <summary>
    /// Controls which holds the Advanced grid , top level data with child data
    /// </summary>
    /// <remarks></remarks>
    public partial class PipelineGridControl : ResultGridView<TicketDTO>
    {
        #region Constructor

        public List<string> operations
        {
            get;
            private set;
        }

        public PipelineGridControl()
            : base(UIConstants.Url.AdvancedView, UIConstants.Sessions.Filter)
        {
            operations = new List<string>();
        }


        #endregion

        #region Page Specific Events

        /// <summary>
        /// Page Init.
        /// Set data source to grid in case data pre-fetched.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void Page_Init(Object sender, EventArgs e)
        {
            base.Page_Init(sender, e);
            GridView = this.ticketGridView;
            GridViewExporter = this.ticketGridViewExporter;
        }

        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks></remarks>
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            //Fetch User operations
            //TTX.Application.PipelineManagement.UI.WebPages.PipelineManagement page = (TTX.Application.PipelineManagement.UI.WebPages.PipelineManagement)this.Page;
            BindDataGrid();
           //operations = page.UserOperations;
        }

        #endregion

        #region Event Handlers

        /// <summary>
        /// Function is called on PreRendering event of Ticket Grid View
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ticketGridView_PreRender(object sender, EventArgs e)
        {
            SetPagerAndItemCount();
        }

        /// <summary>
        /// Register the Script to open the popup while clicking on Grid cell.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param> //TODO: Can be moved to ASCX
        protected void ticketGridView_OnHtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
        {
            ASPxGridView ticketGridView = (ASPxGridView)sender;
            if (e.Cell != null)
            {
                //Register the script to open the popup
               if (operations.Count > 0 && (operations.Contains(AzmanConstants.AdvancedSingleTicketUpdate)))
                {
                   OpenPopup(e);
                }
            }
            if (e.DataColumn.FieldName == UIConstants.TicketData.FieldName.TicketId)
            {
                ReleaseStatusDTO status = (ReleaseStatusDTO)ticketGridView.GetRowValues(e.VisibleIndex, UIConstants.TicketData.FieldName.ReleaseStatus);
                if (!string.IsNullOrEmpty(status.Color))
                {
                    e.Cell.BackColor = Color.FromName(status.Color);
                }
            }
            if (e.DataColumn.FieldName == UIConstants.TicketData.FieldName.PlannedRelease)
            {
                ReleaseCommitmentDTO release = (ReleaseCommitmentDTO)ticketGridView.GetRowValues(e.VisibleIndex, UIConstants.TicketData.FieldName.ReleaseCommitment);
                if (!string.IsNullOrEmpty(release.Color))
                {
                    e.Cell.BackColor = Color.FromName(release.Color);
                }
            }
        }

        /// <summary>
        /// Custom sorting only for TicketId
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ticketGridView_CustomColumnSort(object sender, CustomColumnSortEventArgs e)
        {
            if (e.Column.FieldName == UIConstants.TicketData.FieldName.TicketId)
            {
                e.Handled = true;
                string firstValue = e.Value1.ToString();
                string secondValue = e.Value2.ToString();
                if (firstValue.Length > secondValue.Length)
                {
                    e.Result = 1;
                }
                else
                {
                    if (firstValue.Length == secondValue.Length)
                    {
                        e.Result = Comparer.Default.Compare(firstValue, secondValue);
                    }
                    else
                    {
                        e.Result = -1;
                    }
                }
            }
        }

        #endregion

        #region Override Base Class Functions


        /// <summary>
        /// Override the method to get the data source.
        /// </summary>
        /// <param name="sortBy"></param>
        /// <param name="pageSize"></param>
        /// <param name="startIndex"></param>
        /// <returns></returns>
        [DataObjectMethod(DataObjectMethodType.Select)]
        public override IEnumerable<TicketDTO> GetSourceData(string sortBy, int pageSize, int startIndex)
        {
            var ticketDetailsBdc = new TicketDetailBDC();
            int recordsCount = 0;
            if (Data == null && Context.Session[UIConstants.Sessions.Filter] != null)
            {
                if (pageSize == 0)
                {
                    pageSize = Context.Session[UIConstants.Sessions.TicketsCountSession] != null ? Convert.ToInt32(Context.Session[UIConstants.Sessions.TicketsCountSession]) : 0;
                }
                Data = ticketDetailsBdc.GetTickets(((AdvancedFilterDTO)Context.Session[UIConstants.Sessions.Filter]), sortBy, startIndex, pageSize, out recordsCount);
                Context.Session[UIConstants.Sessions.TicketsCountSession] = recordsCount;

            }
            return Data;
        }


        /// <summary>
        /// method to get the data source count.
        /// </summary>
        /// <returns></returns>
        public int GetSourceDataCount()
        {
            int totalTicketsCount = Context.Session[UIConstants.Sessions.TicketsCountSession] != null ? Convert.ToInt32(Context.Session[UIConstants.Sessions.TicketsCountSession]) : 0;
            //var ticketDetailsBdc = new TicketDetailBDC();
            //if (Context.Session[UIConstants.Sessions.Filter] != null)
            //{
            //    totalTicketsCount = ticketDetailsBdc.GetTicketsCount(((AdvancedFilterDTO)Context.Session[UIConstants.Sessions.Filter]));
            //    Context.Session[UIConstants.Sessions.TicketsCountSession] = totalTicketsCount;
            //}
            return totalTicketsCount;
        }

        /// <summary>
        /// Binds the grid data.
        /// </summary>
        /// <remarks></remarks>
        public override void BindDataGrid()
        {
            base.BindDataGrid();
            pannel.Update();
        }

        /// <summary>
        /// Override the method to export grid to excel sheet with corresponding cell colors
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void GridViewExporter_RenderBrick(object sender, DevExpress.Web.ASPxGridView.Export.ASPxGridViewExportRenderingEventArgs e)
        {
            base.GridViewExporter_RenderBrick(sender, e);
            if ((e.Column as GridViewDataColumn).FieldName == UIConstants.TicketData.FieldName.TicketId && e.RowType != GridViewRowType.Header)
            {
                ReleaseStatusDTO status = (ReleaseStatusDTO)ticketGridView.GetRowValues(e.VisibleIndex, UIConstants.TicketData.FieldName.ReleaseStatus);
                if (!string.IsNullOrEmpty(status.Color))
                {
                    e.BrickStyle.BackColor = Color.FromName(status.Color);
                }
            }
            if ((e.Column as GridViewDataColumn).FieldName == UIConstants.TicketData.FieldName.PlannedRelease && e.RowType != GridViewRowType.Header)
            {
                ReleaseCommitmentDTO release = (ReleaseCommitmentDTO)ticketGridView.GetRowValues(e.VisibleIndex, UIConstants.TicketData.FieldName.ReleaseCommitment);
                if (!string.IsNullOrEmpty(release.Color))
                {
                    e.BrickStyle.BackColor = Color.FromName(release.Color);
                }
            }
        }

        /// <summary>
        /// Method to Bind Data For Export
        /// </summary>
        protected override void BindDataForExport()
        {
            //Get actual release notes and notes instead of short release notes and notes
            GridViewDataTextColumn releaseNotesGridColumn = ticketGridView.Columns[DatabaseConstants.SPParameters.Release] as GridViewDataTextColumn;
            GridViewDataTextColumn notesGridColumn = ticketGridView.Columns[DatabaseConstants.SPParameters.ITNotes] as GridViewDataTextColumn;

            //TODO: Is this required?
            releaseNotesGridColumn.FieldName = DatabaseConstants.Table.Columns.ReleaseNotes;
            notesGridColumn.FieldName = DatabaseConstants.Table.Columns.Notes;
            base.BindDataForExport();
        }

        #endregion

        #region Private Functions
        /// <summary>
        /// Method use to register the script to open the popup
        /// </summary>
        /// <param name="e"></param> //TODO: Can be done in ASCX
        private void OpenPopup(ASPxGridViewTableDataCellEventArgs e)
        {
            string ticketId = e.KeyValue.ToString();
            if (e.DataColumn.FieldName != UIConstants.TicketData.FieldName.TicketId)
            {
                // when mouse Click over cell, Edit pop will be open
               e.Cell.Attributes.Add("Onclick", "OpenNewWindow('" + this + "','" + ticketId + "',event);");
            }
            switch (e.DataColumn.FieldName)
            {
                case UIConstants.TicketData.FieldName.DateSent:
                case UIConstants.TicketData.FieldName.Description:
                case UIConstants.TicketData.FieldName.OwnerName:
                case UIConstants.TicketData.FieldName.Que:
                case UIConstants.TicketData.FieldName.Priority:
                case UIConstants.TicketData.FieldName.RequestorText:
                    e.Cell.ForeColor = Color.DarkCyan;
                    break;
            }
        }

        #endregion

    }
}


THIS IS MY MAIN PAGE:

XML
<%@ Page Language="C#" MasterPageFile="~/TTX_Application.master" AutoEventWireup="true"
    CodeBehind="PipelineManagement.aspx.cs" MaintainScrollPositionOnPostback="true"
    Inherits="TTX.Application.PipelineManagement.UI.WebPages.PipelineManagement"
    Title="IT Request Pipeline (Advanced View)" Theme="TTX" %>

<%@ Register Assembly="DevExpress.Web.v12.1, Version=12.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxMenu" TagPrefix="dxmv" %>
<%@ Register Assembly="DevExpress.Web.v12.1" Namespace="DevExpress.Web.ASPxPopupControl"
    TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v12.1, Version=12.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v12.1, Version=12.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register TagPrefix="ctrl" TagName="pipeLineFilter" Src="~/UserControls/PipelineFilterControl.ascx" %>
<%@ Register TagPrefix="ctrl" TagName="pipeLineGrid" Src="~/UserControls/PipelineGridControl.ascx" %>
<%@ Register TagPrefix="ctrl" TagName="loadPreference" Src="~/UserControls/LoadPreferenceControl.ascx" %>
<%@ Register TagPrefix="ctrl" TagName="savePreference" Src="~/UserControls/SavePreferenceControl.ascx" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v12.1" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v12.1" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphSiteBody" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdateProgress ID="UpdateProgress6" runat="server" DisplayAfter="0" AssociatedUpdatePanelID="uPnlPipeline">
        <ProgressTemplate>
            <div class="progress">
                <div>
                    <img id="Img1" alt="" src="~/Images/ajax-loader_circle.gif"
                         runat="server" /><br />
                    Loading...
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <table style="width: 100%" cellpadding="0px" cellspacing="0px" border="0">
        <tr>
            <td colspan="2">
                <asp:UpdatePanel ID="uPnlPipeline" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <ctrl:pipeLineFilter ID="ctrlPipelineFilter"  runat="server"></ctrl:pipeLineFilter>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </td>
        </tr>
        <tr>
            <td style="padding-removed 2px">
                <table border="0">
                    <tr>
                        <td>
                            <asp:HyperLink ID="lbtnAdmin" runat="server" ForeColor="#983222" Text="Admin" NavigateUrl="~/WebPages/PipelineSyncConfig.aspx"></asp:HyperLink>
                        </td>
                        <td>
                            <asp:Label ID="lbldivider1" runat="server" ForeColor="#983222" Text="|"></asp:Label>
                        </td>
                        <td>
                            <asp:HyperLink ID="lbtnEditableSearch" runat="server" ForeColor="#983222" Text="Editable View" NavigateUrl="~/WebPages/EditableSearchPage.aspx"></asp:HyperLink>
                        </td>
                        <td>
                            <asp:Label ID="lbldivider" runat="server" ForeColor="#983222" Text="|"></asp:Label>
                        </td>
                        <td>
                            <asp:HyperLink ID="hlnkBasicView" runat="server" ForeColor="#983222" Text="Basic View" NavigateUrl="~/WebPages/BasicUserPage.aspx"></asp:HyperLink>
                        </td>
                        <td>
                            <asp:Label ID="lblDivider4" runat="server" ForeColor="#983222" Text="|"></asp:Label>
                        </td>
                        <td>
                            <label  runat="server" id="PreferenceLabel">Preference</label>
                        </td>
                        <td>
                            <ctrl:loadPreference ID="ctrlLoadPreference"  runat="server"></ctrl:loadPreference>
                            <ctrl:savePreference ID="ctrlSavePreference"  runat="server"></ctrl:savePreference>
                        </td>
                        <td>
                            <asp:Label ID="lblDivider3" runat="server" ForeColor="#983222" Text="|"></asp:Label>
                        </td>
                        <td>
                            <asp:LinkButton ID="lbtnExportExcel" ForeColor="#983222" Text="Export to Excel" runat="server" OnClick="lbtnExportExcel_Click"></asp:LinkButton>
                        </td>
                        <td>
                            <asp:Label ID="lblEmpty" runat="server" ForeColor="#983222" Text="|"></asp:Label>
                        </td>
                        <td>
                            <asp:LinkButton ID="lbtnExportPdf" ForeColor="#983222" Text="PDF Export" runat="server" OnClick="lbtnExportPdf_Click"></asp:LinkButton>
                        </td>
                        <td>
                            <asp:Label ID="lblDivider5" runat="server" ForeColor="#983222" Text="|"></asp:Label>
                        </td>
                        <td>
                            <a id="lbtnDownloadHelpDoc" href="../Documents/Pipeline_CorporateView_HowTo_Doc.mht" style="color: #983222" target='_blank'>Help</a>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <table style="width: 100%" cellpadding="0px" cellspacing="0px" border="0">
        <tr>
            <td>
                <ctrl:pipeLineGrid ID="ctrlPipelineGrid"  runat="server"></ctrl:pipeLineGrid>
            </td>
        </tr>
    </table>
</asp:Content>


THIS IS MY MAIN CS CLASS:


C#
using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using TTX.Application.PipelineManagement.Common;
using TTX.Utility.AzmanSecurity.SecurityEngine;

namespace TTX.Application.PipelineManagement.UI.WebPages
{
    /// <summary>
    /// Pipeline Management Landing Page
    /// </summary>
    public partial class PipelineManagement : BasePage
    {

        #region Page Load

        /// <summary>
        /// Page Laod funtion
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void Page_Load(object sender, EventArgs e)
        {
            ctrlPipelineFilter.FillGridData += FillGrid;
            //List<string> operations = UserOperations;
            //if (operations.Count == 0 || !(operations.Contains(AzmanConstants.AdvancedSingleTicketUpdate) || operations.Contains(AzmanConstants.AdvancedReadOnly)))
            //{
            //    HttpContext.Current.Response.Redirect(UIConstants.Url.ErrorMessage + UIConstants.Url.IsAuthorizedFalse);
            //}
            //FillLabels(operations);
            PreferenceLabel.Attributes.Add(UIConstants.OnMouseOver, UIConstants.OpenPreferenceList);
            if (!Page.IsPostBack && Request.QueryString[UIConstants.Preference] != null)
            {
                ctrlPipelineFilter.ClearFilterSelections();
            }
        }

        #endregion

        /// <summary>
        /// Fills the grid.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks></remarks>
        private void FillGrid(object sender, EventArgs e)
        {
            ctrlPipelineGrid.BindDataGrid();
        }

        #region Export Funtionality

        /// <summary>
        /// Funtionality to Export the Grid to Excel Format
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbtnExportExcel_Click(object sender, EventArgs e)
        {
            ctrlPipelineGrid.ExportGridDataToExcel();
        }

        /// <summary>
        /// Export the Grid Data to PDF format
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbtnExportPdf_Click(object sender, EventArgs e)
        {
            ctrlPipelineGrid.ExportGridDataToPDF();
        }


        /// <summary>
        /// Fills the labels.
        /// </summary>
        /// <remarks></remarks>
        private void FillLabels(List<string> aList)
        {
            if (aList != null && aList.Count > 0 && !aList.Contains(AzmanConstants.ConfigurationUpdate))
            {
                lbtnAdmin.Visible = false;
                lbldivider1.Visible = false;
            }
            if (aList != null && aList.Count > 0 && !aList.Contains(AzmanConstants.BasicReadOnly))
            {
                hlnkBasicView.Visible = false;
                lblDivider4.Visible = false;
            }
            (this.Master as TTX_Application).DisplayHeader(UIConstants.PipelineReleaseManagement);
        }

        #endregion

    }
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900