Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
WebDataGrid exporting without data and no style
posted

hi everyone, so here I'm trying to export a WebDataGrid, but when I click on the export, the excel is empty and only the column name are appeared, here is my code:

Imports Infragistics.Web.UI.GridControls
Public Class atte
    Inherits System.Web.UI.Page
    Protected Sub Generate_btn_Click(sender As Object, e As EventArgs) Handles Generate_btn.Click
        Dim ds As New DataSet3
        Dim dt As DataTable = ds.DataTable1
        For i As Integer = 1 To 10
            dt.Rows.Add(i)
        Next
        WebDataGrid1.DataSource = dt
        WebDataGrid1.DataBind()

    End Sub
    Private Sub WebDataGrid1_InitializeRow(sender As Object, e As RowEventArgs) Handles WebDataGrid1.InitializeRow
        e.Row.Items.FindItemByKey("Type").CssClass = "TestCss"
    End Sub

    Protected Sub Export_btn_Click(sender As Object, e As EventArgs) Handles Export_btn.Click
        WebExcelExporter1.Export(WebDataGrid1)
    End Sub
End Class

so I did a workaround and added the generate code before the export function, exported the data successfully but without any style.

 Protected Sub Export_btn_Click(sender As Object, e As EventArgs) Handles Export_btn.Click
        Dim ds As New DataSet3
        Dim dt As DataTable = ds.DataTable1
        For i As Integer = 1 To 10
            dt.Rows.Add(i)
        Next
        WebDataGrid1.DataSource = dt
        WebDataGrid1.DataBind()
        WebExcelExporter1.Export(WebDataGrid1)
    End Sub
 

any help for both issues? 

thanks

Parents Reply Children
No Data