程序出了错误,不知道为什么?
系统说我在下面这个地方出了错误:
using System.Web.UI.WebControls.DataGrid MyDataGrid;
说using无效,
为什么?
我的具体程序如下:
namespace yjs.WebUserControl
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/// <summary>
/// WebUserControl_BlockShown 的摘要说明。
/// </summary>
public class WebUserControl_BlockShown : System.Web.UI.UserControl
{
using System.Web.UI.WebControls.DataGrid MyDataGrid;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
SqlConnection myConnection;
myConnection = new SqlConnection
("server=(local);database=graduate_student;Trusted_Connection=yes");
SqlDataAdapter myCommand = new SqlDataAdapter
("select distinct * from t_news",myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds,"t_news");
MyDataGrid.DataSource= ds.Tables["t_news"].DefaultView;
MyDataGrid.DataBind();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}