This is a migrated thread and some comments may be shown as answers.

RadGrid Export To Excel

9 Answers 391 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zohreh
Top achievements
Rank 1
Zohreh asked on 12 Mar 2013, 10:02 AM
i have RadGrid in userControl of a Content page and when export radgrid data to excel, in exel file , have row with "No child records to display." . find some comment for solve this in internet like use below code :
       protected void WBSRadGrid_PreRender(object sender, EventArgs e)
        {
            WBSRadGrid.MasterTableView.Items[0].Expanded = true;

            if (isExport)
            {
                foreach (GridItem item in WBSRadGrid.MasterTableView.Items)
                {
                    if (item.Expanded)
                    {
                        GridDataItem dItem = item as GridDataItem;
                        GridItem[] items = dItem.ChildItem.NestedTableViews[0].GetItems(GridItemType.NoRecordsItem);
                        if (items.Length > 0)
                        {
                            items[0].Visible = false;

                        }
                    }
                }

            }
        } 
but this not work correctly at all.
what should i do for solve this problem?
please help me.

best regards,
zohreh

9 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Mar 2013, 05:44 AM
Hi,

 Try the following code to hide "No child records to display" when exporting.
C#:
protected void Button5_Click(object sender, EventArgs e)
   {
      foreach (GridNoRecordsItem item in RadGrid1.MasterTableView.GetItems(GridItemType.NoRecordsItem))
       {
           item.Display = false;
       }
       RadGrid1.MasterTableView.ExportToExcel();
       RadGrid1.Rebind();
   }

Thanks,
Shinu
0
Zohreh
Top achievements
Rank 1
answered on 13 Mar 2013, 06:12 AM
i check below code in export to excel button click but my project not work yet correctly.
this foreach not found any NoRecordsItem.
 /////////////////////////////////////////////////////////////////
foreach (GridNoRecordsItem item in WBSRadGrid.MasterTableView.GetItems(GridItemType.NoRecordsItem))
            {
                item.Display = false;
            }

            WBSRadGrid.MasterTableView.ExportToExcel();
            WBSRadGrid.Rebind();
////////////////////////////////////////////////////////////////////
Note: in my web Page everything is ok and there is not any record with "No child records to display." but in Excel file there is "No child records to display.". I dont know why?
 

 
0
Kostadin
Telerik team
answered on 15 Mar 2013, 08:45 AM
Hi Zohreh,

I would suggest you to loop through all the items and if the item has a GridTableView without data in it to set its Visible property to false. I prepared a small example and attached it to this forum post.

Greetings,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Zohreh
Top achievements
Rank 1
answered on 18 Mar 2013, 10:42 AM
thanks for your code,
but i add your code to my solution, in this case new code found some record that fil with "No Record To dispaly" and invisible them.
and not show in User interface but  in excel show them again.
what can I do now?
please help. please

Best regards,
Zohreh

 
0
Kostadin
Telerik team
answered on 21 Mar 2013, 09:45 AM
Hi Zohreh,

Please make sure to create a boolean variable as I did in my sample. This way you could hide the NoRecordTemplate only in the exported format. If you have one make sure you change its value in your code.

All the best,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Zohreh
Top achievements
Rank 1
answered on 07 Apr 2013, 01:16 PM
Hello Dear , 
I Define boolean variable and set it when click on export to excel button and on prerender check it and invisible "No Data row" but it not work correctly.like below code:

       bool isExported = false;
       public void btnExportToExcel_Click(object sender, EventArgs e)
        {
            isExported = true;
            WBSRadGrid.MasterTableView.ExportToExcel();
}
        protected void WBSRadGrid_PreRender(object sender, EventArgs e)
        {
            if (isExported)
            {
                foreach (GridDataItem dataItem in WBSRadGrid.Items)
                {
                    if (dataItem.HasChildItems)
                    {
                        if (dataItem.ChildItem.NestedTableViews.Length > 0 && dataItem.ChildItem.NestedTableViews[0].Items.Count == 0)
                        {
                            dataItem.ChildItem.Visible = false;
                        }
                    }
                }
                WBSRadGrid.Rebind();
            } 
but when recheck visibility of items that change to false those are not changed.
what can i do?
please help
0
Kostadin
Telerik team
answered on 11 Apr 2013, 06:37 AM
Hi Zohreh,

It is hard to say what is the reason for that behavior without your code declaration. Could you please provide us with your RadGrid declaration and the related code behind so this way we could investigate the issue further.

Greetings,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Zohreh
Top achievements
Rank 1
answered on 13 Apr 2013, 07:28 AM
Hello dear,
1-in my solution i have a master page :
1-a:HTML:
<head runat="server">
    <title></title>
    <link href="../CSS/HtmlControlStyle.css" rel="stylesheet" type="text/css" />
    <link href="../CSS/LabelStyle.css" rel="stylesheet" type="text/css" />
    <link href="../CSS/DropDownStyle.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        function mngRequestStarted(ajaxManager, eventArgs) {
            if ((eventArgs.EventTarget.indexOf("btnExportToExcel") != -1) || (eventArgs.EventTarget.indexOf("btnSearch") != -1)
                (eventArgs.EventTarget.indexOf("btnExportToExcel1") != -1) || (eventArgs.EventTarget.indexOf("btnSearch1") != -1)) {
                eventArgs.EnableAjax = false;
            }
        }
    </script>

    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <table style="width: 100%; margin: 0px; padding: 0px;" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <form id="frmMain" runat="server">
                <asp:WebPartManager ID="wpm" runat="server">
                </asp:WebPartManager>
                <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                    <Scripts>
                        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                    </Scripts>
                </telerik:RadScriptManager>
                <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" ClientEvents-OnRequestStart="mngRequestStarted">
                    <ClientEvents OnRequestStart="mngRequestStarted" />
                </telerik:RadAjaxManager>
                <telerik:RadSkinManager ID="RadSkinManager1" runat="server" Skin="Telerik">
                </telerik:RadSkinManager> 

1-b:C# Code : 
       protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                foreach (WebPartDisplayMode mode in wpm.SupportedDisplayModes)
                {
                    ddlDisplayMode.Items.Add(mode.Name);
                }

                ddlDisplayMode.SelectedValue = wpm.DisplayMode.ToString();
            }
            
            WebPart wp1 = (WebPart)wpm.WebParts["ucWBSRad"];
            if (wp1 != null)
            {
                if (wp1.Controls[0] != null)
                {
                    Control radgrid = (Control)wp1.Controls[0].FindControl("WBSRadGrid");
                    Control buttonExport = (Control)wp1.Controls[0].FindControl("btnExportToExcel");
                    Control buttonSearch = (Control)wp1.Controls[0].FindControl("btnSearch");

                    RadAjaxManager1.AjaxSettings.AddAjaxSetting(radgrid, radgrid, null);
                    RadAjaxManager1.AjaxSettings.AddAjaxSetting(buttonExport, buttonExport, null);
                    RadAjaxManager1.AjaxSettings.AddAjaxSetting(buttonSearch, buttonSearch, null);
                }
            }

2-in content page use a usercontrol: 
2-a:HTML :
<%@ Page Language="C#" MasterPageFile="~/MasterPage/MainMasterPage.Master" AutoEventWireup="true"
    CodeBehind="Project_WBSList_UCTelerik.aspx.cs" Inherits="ProjectControl.Project_WBSList_UCTelerik"
    Title="WBS List Page" %>

<%@ Register Src="~/UserControls/UCRadGrid.ascx" TagName="WBSListRad" TagPrefix="ucWBSListRad" %>
<%@ Register Src="~/UserControls/UCRadGrid1.ascx" TagName="WBSListRad1" TagPrefix="ucWBSListRad1" %>

<asp:Content ID="cphContent" ContentPlaceHolderID="cphMain" runat="server">
    <div id="divMainStyle" style="vertical-align: top; overflow: hidden; width: 100%">
        <asp:WebPartZone runat="server" ID="WBSList" BackColor="#EFF3FB" BorderColor="#CCCCCC"
            Font-Names="Tahoma" Padding="6" Width="100%" ForeColor="purple">
            <FooterStyle ForeColor="Green"></FooterStyle>
            <EmptyZoneTextStyle Font-Size="1em" />
            <PartStyle Font-Size="1em" ForeColor="#333333" />
            <TitleBarVerbStyle Font-Size="1em" Font-Underline="False" ForeColor="White" />
            <MenuLabelHoverStyle ForeColor="#D1DDF1" />
            <MenuPopupStyle BackColor="#507CD1" BorderColor="#CCCCCC" BorderWidth="1px" Font-Names="Tahoma"
                Font-Size="0.8em" />
            <MenuVerbStyle BorderColor="#507CD1" BorderStyle="Solid" BorderWidth="1px" ForeColor="White" />
            <PartTitleStyle BackColor="#507CD1" Font-Bold="True" Font-Size="1em" ForeColor="White" />
            <ZoneTemplate>
                <ucWBSListRad:WBSListRad ID="ucWBSRad" runat="server" title="Telerik WBS list"/>
            </ZoneTemplate>
            <MenuVerbHoverStyle BackColor="#EFF3FB" BorderColor="#CCCCCC" BorderStyle="Solid"
                BorderWidth="1px" ForeColor="#333333" />
            <PartChromeStyle BackColor="#EFF3FB" BorderColor="#D1DDF1" Font-Names="Verdana" ForeColor="#333333" />
            <HeaderStyle BackColor="#D1DDF1" Font-Bold="True" Font-Size="1em" ForeColor="#333333"
                HorizontalAlign="Center" />
            <EditVerb Enabled="true" Text="Edit" Description="Edit some Properties related to WBSListUser Control" />
            <MenuLabelStyle ForeColor="White" />
        </asp:WebPartZone>
        <asp:EditorZone ID="ezContent" runat="server" BackColor="#E3EAEB" BorderColor="#CCCCCC"
            BorderWidth="1px" Font-Names="Verdana" Padding="6">
            <FooterStyle BackColor="#C5BBAF" HorizontalAlign="Right" />
            <PartTitleStyle Font-Bold="True" Font-Size="1em" ForeColor="#333333" />
            <PartChromeStyle BorderColor="#C5BBAF" BorderStyle="Solid" BorderWidth="1px" />
            <PartStyle BorderColor="#E3EAEB" BorderWidth="5px" />
            <LabelStyle Font-Size="1em" ForeColor="#333333" />
            <VerbStyle Font-Names="Verdana" Font-Size="1em" ForeColor="#333333" />
            <ErrorStyle Font-Size="5em" />
            <OKVerb Visible="false" />
            <EmptyZoneTextStyle Font-Size="1em" ForeColor="#333333" />
            <ZoneTemplate>
                <asp:PropertyGridEditorPart ID="pgepContent" runat="server" GroupingText="Connection & Table info"  Title="Edit WBS List Info"
                 ChromeType="TitleAndBorder">
                </asp:PropertyGridEditorPart>
            </ZoneTemplate>
            <EditUIStyle Font-Names="Verdana" Font-Size="1em" ForeColor="#333333" />
            <HeaderStyle BackColor="#C5BBAF" Font-Bold="True" Font-Size="1em" ForeColor="#333333" />
            <HeaderVerbStyle Font-Bold="False" Font-Size="1em" Font-Underline="False" ForeColor="#333333" />
            <InstructionTextStyle Font-Size="1em" ForeColor="#333333" />
        </asp:EditorZone>
    </div>

2-b:in C# Code of Content page :
    public partial class Project_WBSList_UCTelerik : System.Web.UI.Page
    {
        #region Load

        protected void Page_Load(object sender, EventArgs e)
        {
            ucWBSRad.DataBind();
            if (ucWBSRad1 != null)
                ucWBSRad1.DataBind();
        }

        public void Page_PreRenderComplete(object sender, EventArgs e)
        {
            RadGrid grid = ucWBSRad.FindControl("WBSRadGrid") as RadGrid;
            ucWBSRad.HideExpandColumnRecursive(grid.MasterTableView);

            RadGrid grid1 = ucWBSRad1.FindControl("WBSRadGrid1") as RadGrid;
            if (grid1 != null)
                ucWBSRad1.HideExpandColumnRecursive(grid1.MasterTableView);

        } 

        #endregion 
        }

3-in userControl i used a RadGrid : 
3-a:HTML : 
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UCRadGrid.ascx.cs" Inherits="ProjectControl.UserControls.UCRadGrid" %>
<link href="../CSS/TextboxStyle.css" rel="stylesheet" type="text/css" />
<link href="../CSS/LabelStyle.css" rel="stylesheet" type="text/css" />
<link href="../CSS/HtmlControlStyle.css" rel="stylesheet" type="text/css" />
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<table>
    <tr>
        <td colspan="3">
            <asp:Label ID="lblMsg" CssClass="ErrorStyle" runat="server"></asp:Label>
        </td>        
    </tr>
    <tr>
        <td>
            <asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click" />
        </td>
        <td>
            <asp:Button ID="btnExportToExcel" runat="server" Text="Export To Excel" OnClick="btnExportToExcel_Click" />
        </td>
        <td>
            <asp:HyperLink ID="lnkCorrespondance" runat="server" Visible="false" NavigateUrl="~\AdminConfig\Correspondence.aspx"
                Target="_blank" Text="Correspondance"></asp:HyperLink>
        </td>
    </tr>
    <tr>
        <td colspan="3">
            <telerik:RadGrid ID="WBSRadGrid" runat="server" 
                OnColumnCreated="WBSRadGrid_ColumnCreated"
                OnNeedDataSource="WBSRadGrid_NeedDataSource" 
                OnItemCreated="WBSRadGrid_ItemCreated" 
                OnItemDataBound="WBSRadGrid_ItemDataBound" 
                OnPreRender="WBSRadGrid_PreRender"
            >
                <ExportSettings IgnorePaging="true" ExportOnlyData="true"></ExportSettings>
                <MasterTableView HierarchyDefaultExpanded="true" HierarchyLoadMode="Client" AllowSorting="true"
                                 EnableNoRecordsTemplate="true" ShowHeadersWhenNoRecords="true"
                                 DataKeyNames="WBS_Id,WBS_Parent_Id" 
                                 AutoGenerateColumns="false"                                  
                                 Width="100%">
                    <SelfHierarchySettings ParentKeyName="WBS_Parent_Id" KeyName="WBS_Id" />
                    <NoRecordsTemplate>
                        <div>
                            There are no records to display
                        </div>
                    </NoRecordsTemplate>
                    <Columns>
                        <telerik:GridBoundColumn DataField="WBS_Id" HeaderText="WBS_Id"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="WBS_Name" HeaderText="WBS Name"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="WBS_Parent_id" HeaderText="Parent_Id"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="WBS_Parent_Name" HeaderText="Parent Name"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="WBS_Code" HeaderText="WBS Code"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ActualStartDate" UniqueName="ActualStartDate" HeaderText="Actual Start Date"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ActualEndDate" HeaderText="Actual End Date"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="BLStartDate" HeaderText="Balance Start Date"></telerik:GridBoundColumn>                                                                        
                        <telerik:GridBoundColumn DataField="BLEndDate" HeaderText="Balance End Date"></telerik:GridBoundColumn>                                                                        
                    </Columns>
                </MasterTableView>
                <ClientSettings AllowExpandCollapse="true" />
            </telerik:RadGrid>
        </td>
    </tr>
</table>

3-b:in C# Code of UserControl :
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Telerik.Web.UI;
using System.Reflection;
using System.Data.SqlClient;
using ProjectControl.WBSList_WebService;
using ProjectControl.PublicClasses;
using System.ComponentModel;
using System.IO;
using Telerik.Web.UI.GridExcelBuilder;
using ProjectControl.ProjectList_WebService;


namespace ProjectControl.UserControls
{
    public partial class UCRadGrid : System.Web.UI.UserControl
    {
        ConnectionInfo cnnInfo;

        #region UserControl Properties

        // please do not change the public property variables name because these names are used so that
        // the objects are shown in the desired order and not alphabetically
        private string _dbServerName;
        [WebDescription("This is Server name that user connect to show Project."),
        WebDisplayName("Server name"),
        WebBrowsable(true),
        Personalizable(true),
        DefaultValue("**")]
        public string A_DBServerName
        {
            get
            {
                _dbServerName = WBSRadGrid.Attributes["ServerName"];
                //txtWBSLevel.Attributes["ServerName"].l = 5;
                return _dbServerName;
            }
            set
            {
                if (value == string.Empty)
                {
                    WBSRadGrid.Attributes["ServerName"] = "**";
                    _dbServerName = "NCEM-NET\\SQL2008_R2";
                }
                else
                {
                    WBSRadGrid.Attributes["ServerName"] = value.ToString();
                    _dbServerName = value.ToString();
                }
            }
        }

        private string _dbName;
        [CategoryAttribute("Table Info"),
        WebDescription("This is Database name that user connect to show Project."),
        WebDisplayName("Database Name"),
        WebBrowsable(true),
        Personalizable(true),
        DefaultValue("**")]
        public string B_DBName
        {
            get
            {
                _dbName = WBSRadGrid.Attributes["DBName"];
                return _dbName;
            }
            set
            {
                if (value == string.Empty)
                {
                    WBSRadGrid.Attributes["DBName"] = "**";
                    _dbServerName = "PmdbForNhtc";
                }
                else
                {
                    WBSRadGrid.Attributes["DBName"] = value.ToString();
                    _dbName = value.ToString();
                }
            }
        }

        private string _dbUserName;
        [WebDescription("This is user name that user connect to show Project."),
        WebDisplayName("User name"),
        WebBrowsable(true),
        Personalizable(true),
        DefaultValue("***")]
        public string C_DBUserName
        {
            get
            {
                _dbUserName = WBSRadGrid.Attributes["DBUserName"];
                return _dbUserName;
            }
            set
            {
                if (value == string.Empty)
                {
                    WBSRadGrid.Attributes["DBUserName"] = "***";
                    _dbServerName = "PrimaveraAppUser";
                }
                else
                {
                    WBSRadGrid.Attributes["DBUserName"] = value.ToString();
                    _dbUserName = value.ToString();
                }
            }
        }

        private string _dbpassword;
        [WebDescription("This is Password that user connect to show Project."),
        WebDisplayName("Password"),
        WebBrowsable(true),
        Personalizable(true),
        DefaultValue("***")]
        public string D_DBPassword
        {
            get
            {
                _dbpassword = WBSRadGrid.Attributes["DBPassword"];
                return _dbpassword;
            }
            set
            {
                if (value == string.Empty)
                {
                    WBSRadGrid.Attributes["DBPassword"] = "***";
                    _dbServerName = "PrimaveraAppUser";
                }
                else
                {
                    WBSRadGrid.Attributes["DBPassword"] = value.ToString();
                    _dbpassword = value.ToString();
                }
            }
        }
        
        [WebDescription("This is tree width."),
        WebDisplayName("tree Width"),
        WebBrowsable(true),
        Personalizable(true),
        DefaultValue("500")]
        public int E_widthNum
        {
            get
            {
                return Convert.ToInt32(WBSRadGrid.Attributes["Width"]);
            }
            set
            {
                WBSRadGrid.Attributes["Width"] = value.ToString();
                WBSRadGrid.ClientSettings.Scrolling.AllowScroll = true;
                WBSRadGrid.ClientSettings.Scrolling.ScrollBarWidth = Unit.Pixel(value);
            }
        }
        
        [WebDescription("This is panel height."),
        WebDisplayName("Panel Height"),
        WebBrowsable(true),
        Personalizable(true),
        DefaultValue("300")]
        public int F_heightNum
        {
            get
            {
                return Convert.ToInt32(WBSRadGrid.Attributes["Height"]);
            }
            set
            {
                WBSRadGrid.Attributes["Height"] = value.ToString();
                WBSRadGrid.ClientSettings.Scrolling.AllowScroll = true;
                WBSRadGrid.ClientSettings.Scrolling.ScrollHeight = Unit.Pixel(value);
            }
        }
        /*
        [WebDescription("This is Grid Row."),
        WebDisplayName("Rows in page"),
        WebBrowsable(true),
        Personalizable(true),
        DefaultValue("10")]
        public string G_PageSizeCount
        {
            get
            {
                return WBSRadGrid.Attributes["RowsInPage"];
            }
            set
            {
                if (value != null)
                {
                    WBSRadGrid.Attributes["RowsInPage"] = value;
                    if (value == "*")
                    {
                        WBSRadGrid.AllowPaging = false;
                    }
                    else
                    {
                        WBSRadGrid.AllowPaging = true;
                        WBSRadGrid.PageSize = Convert.ToInt32(value);
                    }
                }
            }
        }
        */
        public int _ProjectInfo;
        [WebDescription("This is Project Info."),
        WebDisplayName("Project In Zone"),
        WebBrowsable(true),
        Personalizable(true),
        DefaultValue("*")]
        public string G_ProjectInfo
        {
            get
            {
                return WBSRadGrid.Attributes["PrjectInfo"];
            }
            set
            {
                if (value != null)
                {
                    WBSRadGrid.Attributes["PrjectInfo"] = value.ToString();
                    if (value == "*")
                    {
                        _ProjectInfo = Convert.ToInt32(DefineSessions.PrimaveraID);
                    }
                    else
                    {
                        DataTable dt;
                        string strProjInfo=string.Empty ;
                        if (DefineSessions.PDProjectList == null)
                            dt = null;
                        else
                        {
                            dt = (DataTable)DefineSessions.PDProjectList;
                            for (int index = 0; index < dt.Rows.Count - 1; index++)
                            {
                                string str = dt.Rows[index]["CodeTitle"].ToString();
                                if (str.Contains(value))
                                {
                                    int PD_ID = Convert.ToInt32(dt.Rows[index]["PSID"]);
                                    if (Resources.Globals.WebService == "1")
                                    {
                                        WSProjectList _wsprojectList = new WSProjectList();
                                        dt = _wsprojectList.Get_Primavera_Accordance_PD(PD_ID, ref strProjInfo);
                                    }
                                    else
                                    {
                                        ProjectList _projectList = new ProjectList();
                                        dt = _projectList.Get_Primavera_Accordance_PD(PD_ID, ref strProjInfo);
                                    }
                                    if (strProjInfo != string.Empty)
                                    {
                                        throw new NotImplementedException();
                                    }
                                    else
                                    {
                                        if (dt.Rows.Count <= 0)
                                        {
                                            ShowErrorOnCurrentPage("No primavera project is assigned to this project.");
                                        }
                                        else
                                        {
                                            _ProjectInfo = Convert.ToInt32(dt.Rows[0][0]);
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                        if (strProjInfo == string.Empty)
                            ShowErrorOnCurrentPage("Project Info is not valid.");
                        else
                            ShowErrorOnCurrentPage(string.Empty);
                    }
                }
            }
        }

        public System.Drawing.Color _GridHeaderColor;
        [WebBrowsable(true),
         WebDisplayName("Grid Header Color"),
         WebDescription(""),
         Personalizable(true),
         Category("Appearance"),
         DefaultValue("Blue")]
        public System.Drawing.Color H__GridHeaderColor
        {
            get
            {
                return _GridHeaderColor;
            }
            set
            {
                _GridHeaderColor = value;
                WBSRadGrid.HeaderStyle.BackColor = _GridHeaderColor;
            }
        }

        public Boolean _ShowActualStartDate;
        [WebBrowsable(true),
         WebDisplayName("Show 'Actual Start Date'?"),
         WebDescription(""),
         Personalizable(true),
         Category("Appearance"),
         DefaultValue("false")]
        public Boolean I_ShowActualStartDate
        {
            get
            {
                _ShowActualStartDate = Convert.ToBoolean(WBSRadGrid.Attributes["ActualStartColumnIsVisible"]);
                return _ShowActualStartDate;
            }
            set
            {
                _ShowActualStartDate = value;
                WBSRadGrid.Attributes["ActualStartColumnIsVisible"] = _ShowActualStartDate.ToString();
            }
        }

        public Boolean _ShowActualEndDate;
        [WebBrowsable(true),
         WebDisplayName("Show 'Actual End Date'?"),
         WebDescription(""),
         Personalizable(true),
         Category("Test"),
         DefaultValue("false")]
        public Boolean J_ShowActualEndDate
        {
            get
            {
                _ShowActualEndDate = Convert.ToBoolean(WBSRadGrid.Attributes["ActualEndColumnIsVisible"]);
                return _ShowActualEndDate;
            }
            set
            {
                WBSRadGrid.MasterTableView.GetColumn("ActualEndDate").Visible = value;
                _ShowActualEndDate = value;
                WBSRadGrid.Attributes["ActualEndColumnIsVisible"] = _ShowActualEndDate.ToString();
            }
        }


        #endregion

        #region Load

        private Boolean Fill_ConnectionInfo(ref ConnectionInfo cnnInfo)
        {
            if ((_dbServerName == null) || (_dbName == null) ||
                (_dbUserName == null) || (_dbpassword == null))
            {
                ShowErrorOnCurrentPage("Please contact to site admin related to ConnectionInfo.");
                return false;
            }
            else
            {
                ShowErrorOnCurrentPage(String.Empty);
                cnnInfo.ServerName = _dbServerName;
                cnnInfo.DBName = _dbName;
                cnnInfo.UserName = _dbUserName;
                cnnInfo.Password = _dbpassword;
                cnnInfo.XMLorProperty = false;
                if (Resources.Globals.XMLorProperty == "1")
                    cnnInfo.XMLorProperty = true;
                return true;
            }
        }
       
        public DataTable GetDataTable()
         {
             /*
             string strPMDBProjID = DefineSessions.PrimaveraID.ToString();
             if (strPMDBProjID == string.Empty)
             {
                 //ShowErrorOnCurrentPage("Please specify Primavera project,at first.");
                 return null;
             }
              
             int _projectCode = Convert.ToInt32(strPMDBProjID);
             */
             int _projectCode = _ProjectInfo;
             int? _wbsLevel = null;

             DataTable dt = null;

             if (Resources.Globals.WebService == "1")
             {
                 WSWBSInfo wsWBSInfo = new WSWBSInfo();
                 dt = wsWBSInfo.Get_ProjectWBSList(_projectCode, _wbsLevel, cnnInfo.ServerName, cnnInfo.DBName, cnnInfo.UserName, cnnInfo.Password, cnnInfo.XMLorProperty);
             }
             else
             {
                 WBSInfo WBSInfo = new WBSInfo();
                 dt = WBSInfo.Get_ProjectWBSList(_projectCode, _wbsLevel, cnnInfo);
             }
             return dt;
         }
    
        public void Page_Load(object sender, EventArgs e)
        {
            ShowErrorOnCurrentPage(string.Empty);
            if (Assembly.GetAssembly(typeof(ScriptManager)).FullName.IndexOf("3.5") != -1 || Assembly.GetAssembly(typeof(ScriptManager)).FullName.IndexOf("4.0") != 1)
            {
                WBSRadGrid.MasterTableView.FilterExpression = @"it[""WBS_Parent_Id""] = Convert.DBNull";
            }
            else
            {
                WBSRadGrid.MasterTableView.FilterExpression = "WBS_Parent_Id IS NULL";
            }
            cnnInfo = new ConnectionInfo();
            bool _result = true;
            if (Resources.Globals.XMLorProperty == "1")
                _result = Fill_ConnectionInfo(ref cnnInfo);
        }

        public void HideExpandColumnRecursive(GridTableView tableView)
        {
            GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
            foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
            {
                foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
                {
                    nestedView.Style["border"] = "0";

                    Button MyExpandCollapseButton = (Button)nestedView.ParentItem.FindControl("MyExpandCollapseButton");
                    if (nestedView.Items.Count == 0)
                    {
                        if (MyExpandCollapseButton != null)
                        {
                            MyExpandCollapseButton.Style["visibility"] = "hidden";
                        }
                        nestedViewItem.Visible = false;
                    }
                    else
                    {
                        if (MyExpandCollapseButton != null)
                        {
                            MyExpandCollapseButton.Style.Remove("visibility");
                        }
                    }

                    if (nestedView.HasDetailTables)
                    {
                        HideExpandColumnRecursive(nestedView);
                    }
                }
            }
        }

        public void CreateExpandCollapseButton(GridItem item, string columnUniqueName)
        {
            if (item is GridDataItem)
            {
                if (item.FindControl("MyExpandCollapseButton") == null)
                {
                    Button button = new Button();
                    button.Click += new EventHandler(button_Click);
                    button.CommandName = "ExpandCollapse";
                    button.CssClass = (item.Expanded) ? "rgCollapse" : "rgExpand";
                    button.ID = "MyExpandCollapseButton";

                    if (item.OwnerTableView.HierarchyLoadMode == GridChildLoadMode.Client)
                    {
                        string script = String.Format(@"$find(""{0}"")._toggleExpand(this, event); return false;", item.Parent.Parent.ClientID);

                        button.OnClientClick = script;
                    }

                    int level = item.ItemIndexHierarchical.Split(':').Length;
                    if (level > 1)
                    {
                        button.Style["margin-left"] = level * 10 + "px";
                    }

                    TableCell cell = ((GridDataItem)item)[columnUniqueName];
                    cell.Controls.Add(button);
                    cell.Controls.Add(new LiteralControl("&nbsp;"));
                    cell.Controls.Add(new LiteralControl(((GridDataItem)item).GetDataKeyValue(columnUniqueName).ToString()));
                }
            }
        }

        #endregion

        #region Events

        protected void WBSRadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            DataTable dt = GetDataTable();
            if (dt != null)
            {
                WBSRadGrid.DataSource = dt;
            }
            else
            {
                ShowErrorOnCurrentPage("Connection Error");
            }
        }

        protected void WBSRadGrid_ItemCreated(object sender, GridItemEventArgs e)
        {
            CreateExpandCollapseButton(e.Item, "WBS_Id");

            if (e.Item is GridHeaderItem && e.Item.OwnerTableView != WBSRadGrid.MasterTableView)
            {
                e.Item.Style["display"] = "none";
            }

            if (e.Item is GridNestedViewItem)
            {
                e.Item.Cells[0].Visible = false;
            }
        }

        protected void WBSRadGrid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            CreateExpandCollapseButton(e.Item, "WBS_Id");
        }

        protected void WBSRadGrid_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
        {
            if (e.Column is GridExpandColumn)
            {
                e.Column.Visible = false;
            }
            else if (e.Column is GridBoundColumn)
            {
                e.Column.HeaderStyle.Width = Unit.Pixel(100);
            }
        }

        void button_Click(object sender, EventArgs e)
        {
            ((Button)sender).CssClass = (((Button)sender).CssClass == "rgExpand") ? "rgCollapse" : "rgExpand";
        }
        
        void ConfigureExport()
        {
            WBSRadGrid.ExportSettings.ExportOnlyData = true;
            WBSRadGrid.ExportSettings.IgnorePaging = true;
            WBSRadGrid.ExportSettings.OpenInNewWindow = true;
            WBSRadGrid.ExportSettings.FileName = "Test";
            WBSRadGrid.MasterTableView.HierarchyDefaultExpanded = true;
            WBSRadGrid.MasterTableView.DetailTables[0].HierarchyDefaultExpanded = true;
        }

        bool isExported = false;

        public void btnExportToExcel_Click(object sender, EventArgs e)
        {
            isExported = true;
            WBSRadGrid.MasterTableView.ExportToExcel();
            //export();
            /*DataTable dt = GetDataTable();
            if (dt != null)
            {
                //ExporttoExcel(dt);
                //DataTableToExcel(dt);
                ExportDataSetToExcel(dt);
            }
            else
                ShowErrorOnCurrentPage("Connection Error");
            */
            //GridTableRow RowItem = WBSRadGrid.MasterTableView.GetItems(GridItemType.Item)[2] as GridTableRow;
            /*foreach (GridDataItem item in WBSRadGrid.Items)//loops through each grid row
            {
                string v = item.Cells[3].Text;//accessing cell using its ColumnUniqueName
            }

            foreach (GridNoRecordsItem item in WBSRadGrid.MasterTableView.GetItems(GridItemType.NoRecordsItem))
            {
                item.Display = false;
            }*/
            /*isExported = true;
            if (isExported)
            {
                foreach (GridDataItem dataItem in WBSRadGrid.Items)
                {
                    if (dataItem.HasChildItems)
                    {
                        if (dataItem.ChildItem.NestedTableViews.Length > 0 && dataItem.ChildItem.NestedTableViews[0].Items.Count == 0)
                        {
                            dataItem.ChildItem.Visible = false;
                        }
                    }
                }
            }*/
            //WBSRadGrid.Rebind();
            //WBSRadGrid.MasterTableView.ExportToExcel();
            //WBSRadGrid.Rebind();
        }

        protected void WBSRadGrid_PreRender(object sender, EventArgs e)
        {
            WBSRadGrid.MasterTableView.GetColumn("ActualStartDate").Visible = _ShowActualStartDate;
            WBSRadGrid.MasterTableView.Columns.FindByUniqueName("ActualStartDate").Visible = _ShowActualStartDate;
            if (isExported)
            {
                foreach (GridDataItem dataItem in WBSRadGrid.Items)
                {
                    if (dataItem.HasChildItems)
                    {
                        if (dataItem.ChildItem.NestedTableViews.Length > 0 && dataItem.ChildItem.NestedTableViews[0].Items.Count == 0)
                        {
                            dataItem.ChildItem.Visible = false;
                        }
                    }
                }
                WBSRadGrid.Rebind();
            }
            foreach (GridDataItem dataItem in WBSRadGrid.Items)
            {
                if (dataItem.HasChildItems)
                {
                    if (dataItem.ChildItem.NestedTableViews.Length > 0 && dataItem.ChildItem.NestedTableViews[0].Items.Count != 0)
                    {
                        for (int i = 0; i < dataItem.ChildItem.NestedTableViews[0].Items.Count; i++)
                        {
                            //Actual Start Date
                            dataItem.ChildItem.NestedTableViews[0].Items[i].Cells[7].Visible = _ShowActualStartDate;
                        }
                    }
                }
            }
            WBSRadGrid.Rebind();
        }

        public void btnSearch_Click(object sender, EventArgs e)
        {
            DataTable dt = GetDataTable();
            if (dt != null)
            {
                WBSRadGrid.DataSource = dt;
                foreach (GridDataItem dataItem in WBSRadGrid.Items)
                {
                    if (dataItem.HasChildItems)
                    {
                        if (dataItem.ChildItem.NestedTableViews.Length > 0 && dataItem.ChildItem.NestedTableViews[0].Items.Count == 0)
                        {
                            dataItem.ChildItem.Visible = false;
                        }
                    }
                }
                WBSRadGrid.Rebind();
            }
        }

       #endregion

        #region Excel
        /*
        private void Export(GridTableView gridTableView, Page Page, string FileName)
        {
            Microsoft.Office.Interop.Excel.Application objExcel;
            Microsoft.Office.Interop.Excel.Workbook objBook;
            Microsoft.Office.Interop.Excel.Worksheet objSheet; 
            Microsoft.Office.Interop.Excel.Range objRange; 
            Microsoft.Office.Interop.Excel.Range objSearchRange;
            try 
       {        
                string strFileName;

         * 

                //Changing the CurrentUICulture to "en-US" before any operation
                System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US")

                //Create a unique file name
                if (FileName == "")
                    FileName = Environment.UserName.Replace(".", "_") + "_" + System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt").Replace(".", "_").Replace(":", "_").Replace(" ", "_").Replace("/", "_") + "_ExportToExcelFile.xls";
                else
                    FileName = Environment.UserName.Replace(".", "_") + "_" + System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt").Replace(".", "_").Replace(":", "_").Replace(" ", "_").Replace("/", "_") + "_" + FileName;


                //The full path where the excel file will be stored
                strFileName = AppDomain.CurrentDomain.BaseDirectory.Replace("/", "\\") + "ExportedFiles\\";
                strFileName += FileName;

                DS_MyDataset.Tables.Add();

                for (int index = 0; index < gridTableView.Columns.Count-1; index++)
   {
                    if(gridTableView.Columns[i].Visible == true)
                        DS_MyDataset.Tables[0].Columns.Add(gridTableView.Columns[i].HeaderText);
 
   }

                for (int i = 0; i < gridTableView.Columns.Count-1; i++)
   {
                    int k=0;
                    DataRow dr= DS_MyDataset.Tables[0].NewRow();
                    for (int j = 0; j< gridTableView.Columns.Count-1; i++)
       {
                        if (gridTableView.Columns[j].Visible == true) 
                            if(gridTableView.Items[i].Cells[j].Text != "&nbsp;")
                                dr[k] = gridTableView.Items[i].Cells[j].Text;
                            k ++;
       }  
   }

                //Creating a new object of the Excel application object
                objExcel = new Microsoft.Office.Interop.Excel.Application();
                //Hiding the Excel application
                objExcel.Visible = false;
                //Hiding all the alert messages occurring during the process
                objExcel.DisplayAlerts = false;

                //Adding a Workbooks to the Excel object
                objBook = objExcel.Workbooks.Add();
                //Saving the Workbook as a normal workbook format
                objBook.SaveAs(strFileName, Excel.XlFileFormat.xlWorkbookNormal);

                //Get the reference to the first sheet in the workbook
                objSheet = CType(objBook.Sheets.Item(1), Excel.Worksheet);



                //Optionally name the worksheet
                //objSheet.Name = "First Sheet"
                //You can even set the font attributes of a range of cells in the sheet. Here we have set the fonts to bold.
                objSheet.Range("A3", "H3").Font.Bold = true;
                string rng;
                rng = "H" & (DataGrid.Items.Count + 1).ToString;
                objSheet.Range("A3", rng.ToString).NumberFormat = "@";
                //objSheet.Columns("K").NumberFormat = "@"

                //Get the cells collection of the sheet, to write the data.
                objRange = objSheet.Cells;
                objRange = objSheet.Range("A3", "H3");

                //zsf start
                objSearchRange = objSheet.Range("A1", "H1");
                objSearchRange.Merge();
                //objSearchRange.Value = strDiscipline.Substring(6, strDiscipline.Length - 6) + "//" + strMaterial.Trim
                objSearchRange.Value = strDiscipline + "//" + strMaterial.Trim;
                //zsf end

                //Calling the function to write the dataset data in the cells of the first sheet.
                WriteData(DS_MyDataset.Tables(0), objRange);

                //Setting the width of the specified range of cells so as to absolutely fit the written data.
                objSheet.Range("A3", "H3").EntireColumn.AutoFit();

                //Saving the worksheet.
                objSheet.SaveAs(strFileName);

                WindowManagement.openWindowForFile("http://" + Page.Request.Url().Host() + Page.Request.ApplicationPath + "/ExportedFiles/" + FileName, Page)
                FileName = "http://" + Page.Request.Url().Host() + Page.Request.ApplicationPath + "ExportedFiles/" + FileName;
       }
       catch (Exception)
       {
                Page.Response.Write(ex.Message);
       }
            finally
            {
                //Close the Excel application
                objExcel.Quit();;

                //Release all the COM objects so as to free the memory
                ReleaseComObject(objRange);
                ReleaseComObject(objSheet);
                ReleaseComObject(objBook);
                ReleaseComObject(objExcel);

                //Set the all the objects for the Garbage collector to collect them.
                objExcel = null;
                objBook = null;
                objSheet = null;
                objRange = null;

                //Specifically call the garbage collector.
                System.GC.Collect();
            }
        }
        */
        protected void export()
        {
            string path = "c:\\test";

            Microsoft.Office.Interop.Excel.Application xlApp;
            Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
            Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
            object misValue = System.Reflection.Missing.Value;

            xlApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
            xlWorkBook = xlApp.Workbooks.Add(misValue);
            xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

            //DataTable dt = GetDataTable();
            /*for (i = 0; i <= dt.Rows.Count - 1; i++)
            {
                for (j = 0; j <= dt.Columns.Count - 1; j++)
                {
                    data = dt.Rows[i].ItemArray[j].ToString();
                    xlWorkSheet.Cells[i + 1, j + 1] = data;
                }
            }
            */

            GridTableView gridTableView = WBSRadGrid.MasterTableView;
            for (int index = 0; index < gridTableView.Columns.Count; index++)
            {
                if (gridTableView.Columns[index].Visible == true)
                   xlWorkSheet.Cells[1,index+1] = gridTableView.Columns[index].HeaderText;

            }

            DataTable dt = GetDataTable();            
            for (int i = 0; i < dt.Rows.Count-1; i++)
            {
                for (int j = 0; j < dt.Columns.Count-1; j++)
                {
                    xlWorkSheet.Cells[i + 2, j + 1] = dt.Rows[i][j];
                }
            }
            
            xlWorkBook.SaveAs(path + ".xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
            xlWorkBook.Close(true, misValue, misValue);
            xlApp.Quit();

            releaseObject(xlWorkSheet);
            releaseObject(xlWorkBook);
            releaseObject(xlApp);

            //MessageBox.Show("Excel file created , you can find the file c:\\csharp.net-informations.xls");
        }

        private void releaseObject(object obj)
        {
            try
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
                obj = null;
            }
            catch (Exception ex)
            {
                obj = null;
                //MessageBox.Show("Exception Occured while releasing object " + ex.ToString());
            }
            finally
            {
                GC.Collect();
            }
        }

        private void ExporttoExcel(DataTable table)
        {
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.ClearHeaders();
            HttpContext.Current.Response.Buffer = true;
            HttpContext.Current.Response.ContentType = "application/ms-excel";
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=Reports.xls");
            HttpContext.Current.Response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">");

            HttpContext.Current.Response.Charset = "utf-8";
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250");
            //sets font
            HttpContext.Current.Response.Write("<font style='font-size:10.0pt; font-family:Calibri;'>");
            HttpContext.Current.Response.Write("<BR><BR><BR>");
            //sets the table border, cell spacing, border color, font of the text, background, foreground, font height
            HttpContext.Current.Response.Write("<Table border='1' bgColor='#ffffff' " +
              "borderColor='#000000' cellSpacing='0' cellPadding='0' " +
              "style='font-size:10.0pt; font-family:Calibri; background:white;'> <TR>");
            //am getting my grid's column headers
            GridTableView gridTableView = WBSRadGrid.MasterTableView;
            int columnscount = gridTableView.Columns.Count;

            for (int j = 0; j < columnscount; j++)
            {      //write in new column
                HttpContext.Current.Response.Write("<Td>");
                //Get column headers  and make it as bold in excel columns
                HttpContext.Current.Response.Write("<B>");
                HttpContext.Current.Response.Write(gridTableView.Columns[j].HeaderText.ToString());
                HttpContext.Current.Response.Write("</B>");
                HttpContext.Current.Response.Write("</Td>");
            }
            HttpContext.Current.Response.Write("</TR>");
            foreach (DataRow row in table.Rows)
            {//write in new row
                HttpContext.Current.Response.Write("<TR>");
                for (int i = 0; i < table.Columns.Count; i++)
                {
                    HttpContext.Current.Response.Write("<Td>");
                    HttpContext.Current.Response.Write(row[i].ToString());
                    HttpContext.Current.Response.Write("</Td>");
                }

                HttpContext.Current.Response.Write("</TR>");
            }
            HttpContext.Current.Response.Write("</Table>");
            HttpContext.Current.Response.Write("</font>");
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();
        }

        public static void DataTableToExcel(DataTable tbl)
        {
            HttpContext context = HttpContext.Current;
            context.Response.Clear();
            foreach (DataColumn c in tbl.Columns)
            {
                context.Response.Write(c.ColumnName + ";");
            }
            context.Response.Write(Environment.NewLine);
            foreach (DataRow r in tbl.Rows)
            {
                for (int i = 0; i < tbl.Columns.Count; i++)
                {
                    context.Response.Write(r[i].ToString().Replace(";", string.Empty) + ";");
                }
                context.Response.Write(Environment.NewLine);
            }
            //context.Response.ContentType = "text/csv";
            //context.Response.AppendHeader("Content-Disposition",
            //    "attachment; filename=export.csv");

            context.Response.ContentType = "application/vnd.ms-excel";
            context.Response.AppendHeader("Content-Disposition",
                "attachment; filename=export.xlsx");
            context.Response.End();
        }

        public static void ExportDataSetToExcel(DataTable dt)
        {
            HttpResponse response = HttpContext.Current.Response;

            // first let's clean up the response.object
            response.Clear();
            response.Charset = "";

            // set the response mime type for excel
            //response.ContentType = "application/vnd.ms-excel";
            HttpContext.Current.Response.ContentType = "application/ms-excel";
            response.AddHeader("Content-Disposition", "attachment;filename=Report.xls");

            // create a string writer
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    // instantiate a datagrid
                    DataGrid dg = new DataGrid();
                    dg.DataSource = dt;
                    dg.DataBind();
                    dg.RenderControl(htw);
                    response.Write(sw.ToString());
                    response.End();
                }
            }
        }

        #endregion

        #region Error

        private void ShowErrorOnCurrentPage(string Msg)
        {
            lblMsg.Text = Msg;
        }

        #endregion

    }
}


Best regards,
zohreh
0
Kostadin
Telerik team
answered on 17 Apr 2013, 12:19 PM
Hello Zohreh,

I noticed that after hiding the NoRecords you rebind the grid again. Could you please remove the Rebind() method (WBSRadGrid.Rebind();) and let me know about the result?

All the best,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Zohreh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Zohreh
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or