0

i have dev express ASPxGridView. the column and data for the gridview will be dynamically based on the dropdown value.

   If type = "procedure" Then
        SqlDataSource2.SelectCommandType = SqlDataSourceCommandType.StoredProcedure
    Else
        SqlDataSource2.SelectCommandType = SqlDataSourceCommandType.Text
    End If

    SqlDataSource2.SelectCommand = rptquery

    Try
        SqlDataSource2.DataBind()
        dataview1 = SqlDataSource2.Select(System.Web.UI.DataSourceSelectArguments.Empty)
        gv.DataSourceID = "SqlDataSource2"
        For Each dc In dataview1.Table.Columns
            Dim DynamicColumn = New DevExpress.Web.ASPxGridView.GridViewDataTextColumn()
            DynamicColumn.FieldName = dc.ColumnName
            DynamicColumn.Caption = dc.ColumnName

            gv.Columns.Insert(i, DynamicColumn)
            i = i + 1

        Next
        gv.DataBind()

    Catch ex As Exception

    End Try

Then i have export button to excel. my problem is it will only export the column name of the gridview into the excel sheey. data is empty. but in gridview data is shown. please help me on this issue.

user1126128
  • 13
  • 1
  • 6

1 Answers1

0

Make sure that you have bound ASPxGridView prior using the using the ASPxGridViewExporter.Write*** method:

'SqlDataSource2.DataBind()
'dataview1 = SqlDataSource2.Select(System.Web.UI.DataSourceSelectArguments.Empty)

ASPxGridViewExporterInstance.GridView = gv
gv.DataSource = SqlDataSource2
ASPxGridViewExporterInstance.Write***
Mikhail
  • 9,186
  • 4
  • 33
  • 49