我有开发表达ASPxGridView。 gridview的列和数据将根据下拉值动态生成。
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
然后我有excel的导出按钮。我的问题是它只会将gridview的列名导出到excel sheey中。数据是空的。但是在gridview数据中显示。 请帮我解决这个问题。
答案 0 :(得分:0)
确保在使用ASPxGridViewExporter.Write ***方法之前绑定了ASPxGridView:
'SqlDataSource2.DataBind()
'dataview1 = SqlDataSource2.Select(System.Web.UI.DataSourceSelectArguments.Empty)
ASPxGridViewExporterInstance.GridView = gv
gv.DataSource = SqlDataSource2
ASPxGridViewExporterInstance.Write***