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
155
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
No Data
Reply
  • 20255
    Offline posted

    Hello,

    Thank you for contacting us!

    I've created a sample based on your configuration and the styles are exported as expected, please do have a look. As you shared only your code behind, I am unable to determine whether the Initialize_rows is handled appropriately. Could you please make sure that it is bound on page_load, or though the Grid markup.

    In order to run the sample, please make sure that there is a styleset file in the ig_res folder.

    Looking forward to your reply.

    WDGStylesExport.zip

Children