急,求助vs2003Datagrid内容转excel中出错!
我是把vs2003Datagrid内容转到excel中出错,我的Datagrid是分页的,要是Datagrid里的内容不足一页就能转进excel,要是多于一页就出现错误。 
 错误页面是这样显示的,急需各位高手帮忙!!!!   
 类型“DataGridLinkButton”的控件“MyDataGrid__ctl1__ctl1”必须放在具有   runat=server   的窗体标记内
------解决方案--------------------你再弄一个DataGrid,专门用来下载 
 在你绑定第一个的时候同时也把第二个一起绑定了,但是第二个不用显示出来 
 第二个不要分页这样下载就不会出错了 
  <div style= "display:none ">  
  <asp:DataGrid id=Grid2>  
  </asp:DataGrid>  
  </div>  
 这样弄
------解决方案--------------------错误原因是有分页或排序时,分页和排序按钮都是服务端控件,用HtmlTextWriter,再grid.RenderControl(writer)的形式会由于这类控件无法转换而出现错误!可以使用datatable导出excel, 
 public static void DataTableToExcel(HttpResponse re, DataTable dt, string filename) 
 		{ 
 			re.Clear(); 
 			re.ContentType =  "application/vnd.ms-excel "; 
 			re.AddHeader( "Content-Disposition ",  "attachment; filename= " + System.Web.HttpUtility.UrlEncode(filename,System.Text.Encoding.UTF8)+ ".xls "); 
 			re.Write(ExportHTML(dt)); 
 			re.End(); 
 		} 
------解决方案--------------------DataGrid1.DataSource = this.GetDataSource();    
 DataGrid1.DataBind(); 
 Response.Clear(); 
 Response.Buffer = true; 
 Response.ContentType            =  "application/vnd.ms-excel "; 
 Response.Charset                    =  "gb2312 "; 
 EnableViewState                     = false; 
 System.IO.StringWriter tw       = new System.IO.StringWriter(); 
 System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); 
 DataGrid1.RenderControl(hw ); 
 Response.Write(tw.ToString()); 
 Response.End();
------解决方案--------------------学习了。。