Problem With the Export to excel.

2 posts, 0 answers
  1. Sankar
    Sankar avatar
    1 posts
    Member since:
    Jun 2015

    Posted 10 Sep 2015 Link to this post

    Hi Telerik,

                   I have a Problem With the Export to excel. In my case, I created the multiple radgrids dynamically from Code - behind and add it into the Placeholder. I have enabled the default Export to excel button for all grids. I haven't use any ajax panels, but I use Update panel. When i click the default Export to excel button, all grids are invisible and excel did not generated.


       Dim dset As DataSet
            Dim col_count As Integer

            For i As Integer = 0 To c - 1

                Dim radgrid1 As New Telerik.Web.UI.RadGrid
                radgrid1.ID = "RadGrid" & i
                radgrid1.ExportSettings.Excel.Format = GridExcelExportFormat.Html
                radgrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top
                radgrid1.MasterTableView.PageSize = "10"
                radgrid1.MasterTableView.CommandItemSettings.ShowExportToExcelButton = True
                radgrid1.MasterTableView.DataKeyNames = New String() {"employee_id"}
                radgrid1.ExportSettings.ExportOnlyData = True

                radgrid1.ExportSettings.FileName = Pub_dset.Tables("tblCount").Rows(i).Item("sub_heading")
                radgrid1.MasterTableView.Caption = "Sub Heading - " & Pub_dset.Tables("tblCount").Rows(i).Item("sub_heading")
                radgrid1.AutoGenerateColumns = False
                radgrid1.ClientSettings.ClientEvents.OnCommand = "onRequestStart('this')"
                dset = DAL.details(9, 4, "", "", "", 0, 0, 0, CDate(Now), CDate(Now), CDate(Now), "", "", "", 0, "", "", 0, 0, i, "", 0, "", 0, 0, "", 0, CDate(Now), "tblBind")
                col_count = dset.Tables("tblBind").Columns.Count
                col_count = dset.Tables("tblBind").Columns.Count

                For j As Integer = 0 To dset.Tables("tblBind").Columns.Count - 1
                    Dim Bcol As New GridBoundColumn
                    Bcol.DataField = dset.Tables("tblBind").Columns(j).ColumnName
                    Bcol.UniqueName = dset.Tables("tblBind").Columns(j).ColumnName
                    Bcol.HeaderText = dset.Tables("tblBind").Columns(j).ColumnName
                    Bcol.ShowFilterIcon = True
                    Bcol.AllowFiltering = True
                    Bcol.AllowSorting = True
                    Bcol.ItemStyle.Wrap = False
                    If Bcol.UniqueName = "employee_id" Or Bcol.UniqueName = "emp_no" Then
                        radgrid1.MasterTableView.GetColumn(Bcol.UniqueName).Display = False
                    End If
                    If Bcol.DataField = "emp_name" Then
                        Bcol.HeaderText = "Employee Name"
                    End If
                radgrid1.DataSource = dset.Tables("tblBind")

                PlaceHolder1.Controls.Add(New LiteralControl("<br><br>"))


    Please help me resolve this...

    its very urgent...

  2. Eyup
    Eyup avatar
    4071 posts

    Posted 11 Sep 2015 Link to this post

    Hi Sankar,

    First of all, please note that the NeedDataSource event is the mandatory way when you need to bind the grid to a programmatic data source in the code-behind. It is important that you are not using DataBind() to bind the grid. Performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Exporting, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations.  Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:
    Declarative DataSource
    Programmatic Data Binding

    If you need to refresh the grid content on an external action, let's say an outside Button click, you can simply use the RadGrid1.Rebind() method to do that. The DataSource property should only be set inside the NeedDataSource event handler.

    Exporting from an ajaxified grid requires additional handling, therefore, I suggest that you replace the UpdatePanel with a RadAjaxPanel and implement the solution provided in the following article:

    Hope this helps.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top