Disabling Datagrid Sort for excel export VB.net <p>Been stuck on this issue for a while now finally narrowed it down to the fact that <code>AllowSorting</code> is <code>True</code>. When I try to run the excel export With sorting, excel opens up into a blank document without any gridlines. Turned it off and the data appears as expected. I thought that if i turned off the sorting in the excel export button click event, then turn it back on afterwards, this would fix the issue, however this has not seemed to be the case. </p> <p>I have also tried shifting where I turn off page sorting just to make sure I didn't place it in the wrong spot but still does not seem to change the result of the blank page. </p> <p>Below is the coding I am using. I did read some talk about using a <code>BindingSource</code> but that also did not seem to work for me. </p> <p>Am I missing a step or doing something wrong?</p> <pre><code> Dim tw As New StringWriter() Dim hw As New HtmlTextWriter(tw) Dim frm As HtmlForm = New HtmlForm() Response.ContentType = "application/vnd.ms-excel" Response.AddHeader("content-disposition", "attachment;filename=" &amp; "Facility Detail Report" &amp; ".xls") Response.Charset = "" EnableViewState = False dgCustomers.AllowPaging = False dgCustomers.AllowSorting = False 'Dim BindingSource As New BindingSource 'BindingSource.DataSource = dgCustomers.DataSource() 'dgCustomers.DataSource = BindingSource.DataSource dgCustomers.DataBind() Controls.Add(frm) frm.Controls.Add(dgCustomers) frm.RenderControl(hw) Response.Write(tw.ToString()) Response.End() dgCustomers.AllowPaging = True dgCustomers.AllowSorting = True dgCustomers.DataBind() </code></pre>