Posted on: 11/17/2012 12:48:31 AM | Views : 436

I have a page with a ListView that displays data. The ListView formats the data via several asp:placeholders that are manipulated when ItemDataBound event of the ListView is fired. Now, the code below successfully creates an Excel file and sends it to the client. However, I have no idea how to call the _ItemDataBound event of the virtual control so that the Excel export is formatting in the same manner as the ListView displayed on the page.
 
Protected Sub LinkButtonExportToExcel_Click(sender As Object, e As EventArgs) Dim FI As New FileInfo("C:\Documents And Settings\holled\desktop\test.xls") Dim stringWriter As New StringWriter Dim htmlWrite As New HtmlTextWriter(stringWriter) Dim ListViewExport As New ListView ListViewScheduleExport.RenderControl(htmlWrite) Dim vw As StreamWriter = New StreamWriter("C:\Documents And Settings\holled\desktop\test.xls", True) string ...

Go to the complete details ...