出现这个错误!可是我已经把DataGrid放在 ruant=server里了~~
类型“DataGridLinkButton”的控件“DataGrid1__ctl2__ctl0”必须放在具有 runat=server 的窗体标记内。这是HTML代码~~
<%@ Page CodeBehind="file1.aspx.cs" Language="c#" AutoEventWireup="false" Inherits="A911.file1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<title>jjjjj</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="vbscript">
<!--
Function button1_OnClick()  if trim(document.getElementByID("ID").value)=""Then  msgbox"您没有填写帐号或密码请确认和从新填写"
  else
  from1.submit
  end if
  end Function
 --> 
</script>
</HEAD>
<body>
<form method="post" id="from1" name="from1" action="WebForm14.aspx">
<table width="1020" height="511" border="1">
<tr>
<td height="64" align="middle" valign="top"><img src="_tu/pay.jpg" width="376" height="50"><img src="_tu/tou.gif" width="800" height="60"></td>
</tr>
<tr>
<td align="left" valign="top">
<p>
<p>请输入您要添加公司名字:</p>
<input type="text" name="ID" id="ID" size="45"> <input id="button1" name="button1" type="button" value="提交">
<input type="reset" name="rest" value="重写">
<P>
<asp:DataGrid id="DataGrid1" runat="server" AllowSorting="True" PageSize="5" AllowPaging="True" AllowCustomPaging="false" CellPadding="4" BorderWidth="1px" BorderColor="#A0ABEB" BorderStyle="Solid" BackColor="White" GridLines="Vertical" ForeColor="Black" ShowFooter="True"></asp:DataGrid></P>
</td>
&nbsp;</TD>
</tr>
</table>
</form>
</body>
</HTML>
这是 执行代码
private void Page_Load(object sender, System.EventArgs e)
{
DataGrid1.AllowPaging = true;
DataGrid1.PagerStyle.Mode = PagerMode.NumericPages;
DataGrid1.PagerStyle.PageButtonCount =5;
DataGrid1.PageSize =5; if (!Page.IsPostBack) 
{

SqlConnection myConnection;
myConnection=new SqlConnection("server=localhost; database=A911;user id=sa;password=") ;
//判断拥护要查找的时间(s6)是否在fei1表中存在
SqlDataAdapter x1=new SqlDataAdapter("select * from gs",myConnection);////这里可以排序     
DataSet ds = new DataSet();
x1.Fill(ds,"fei1");
DataGrid1.DataSource=ds;
DataGrid1.DataBind();// 在此处放置用户代码以初始化页面
}
}