求助高手DataGrid导为Excel的问题
我的程序总是出现莫名的状况:
错误说明:
“/BillPrint”应用程序中的服务器错误。
--------------------------------------------------------------------------------
类型“DataGridLinkButton”的控件“DataGrid1__ctl1__ctl1”必须放在具有 runat=server 的窗体标记内。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Web.HttpException: 类型“DataGridLinkButton”的控件“DataGrid1__ctl1__ctl1”必须放在具有 runat=server 的窗体标记内。
源错误:
行 72: System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
行 73: System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
行 74: this.DataGrid1.RenderControl(oHtmlTextWriter);
行 75: Response.Write(oStringWriter.ToString());
行 76: Response.End();
源文件: e:\inetpub\wwwroot\billprint\webform4.aspx.cs 行: 74
可是我确实把DataGrid放在里面了啊,如下(网页源码):
<%@ Page language="c#" Codebehind="WebForm4.aspx.cs" AutoEventWireup="false" Inherits="BillPrint.WebForm4" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm4</title>
<meta name="vs_snapToGrid" content="False">
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 104; LEFT: 9px; POSITION: absolute; TOP: 38px" runat="server"
Width="944px" AllowPaging="True" PageSize="20" CellPadding="4" BackColor="White" BorderWidth="1px"
BorderStyle="None" BorderColor="#3366CC">
<SelectedItemStyle Font-Bold="True" ForeColor="#CCFF99" BackColor="#009999"></SelectedItemStyle>
<ItemStyle ForeColor="#003399" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#CCCCFF" BackColor="#003399"></HeaderStyle>
<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>
<PagerStyle HorizontalAlign="Left" ForeColor="#003399" Position="Top" BackColor="#99CCCC" Mode="NumericPages"></PagerStyle>
</asp:DataGrid>
<asp:Button id="Button2" style="Z-INDEX: 107; LEFT: 145px; POSITION: absolute; TOP: 10px" runat="server"
Width="109" Height="24" Text="生成Excel表"></asp:Button>
<asp:Button id="Button1" style="Z-INDEX: 106; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"
Width="109px" Height="24px" Text="数据预览"></asp:Button></FONT>
</form>
</body>
</HTML>
请各位高手帮帮忙吧,这是上班的第一个程序,会要人命的啊!!!!!!!!!!