不知是哪里错了,请帮忙看一下。

yyang_kj 2003-08-07 10:32:25
public class idbSample : System.Web.UI.Page
{

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

protected System.Web.UI.WebControls.DataGrid FormatDataGrid;


private DataSet _dsContacts;

private void Page_Load(object sender, System.EventArgs e)
{

_dsContacts = new DataSet();
_dsContacts.ReadXml(Server.MapPath("Contacts.xml"));
DataColumn[] dcPk = {_dsContacts.Tables["Contact"].Columns["Email"]};
_dsContacts.Tables["Contact"].PrimaryKey = dcPk;

if (!Page.IsPostBack )
{
BindContacts();
}
}

private void BindContacts()
{
DataView dv = new DataView(_dsContacts.Tables["Contact"]);
dv.Sort = "LastName, FirstName";
FormatDataGrid.DataSource = dv;
FormatDataGrid.DataBind();
}

protected string FormatFullName(object FirstName, object LastName)
{

return (string)LastName + ", " + (string)FirstName;
}

protected void dgContacts_ItemDataBound(object source,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{

string isManager = (string)DataBinder.Eval(e.Item.DataItem, "Manager");

if (isManager == "1")
{
// ' 设定文字和背景颜色
e.Item.Cells[2].Text = "经理";
e.Item.Cells[2].Style.Add("font-weight", "bold");
e.Item.Cells[2].ForeColor = System.Drawing.Color.Red;
e.Item.BackColor = System.Drawing.Color.AliceBlue;
}
else
{
e.Item.Cells[2].Text = "普通员工";
}
}
}
}

出错提示:
“/DataGrid”应用程序中的服务器错误。
--------------------------------------------------------------------------------

编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误信息: CS0234: 类型或命名空间名称“Global”在类或命名空间“System.Web.UI.WebControls.DataGrid”中不存在(是否缺少程序集引用?)

源错误:



行 26:
行 27: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
行 28: public class Global_asax : DataGrid.Global {
行 29:
行 30: private static bool __initialized = false;


源文件: c:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\datagrid\827e165f\a4dd7967\8nectolt.0.cs 行: 28

不知道是哪里错了,请问为什么?
...全文
25 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2003-08-08
  • 打赏
  • 举报
回复
build the project in VS.NET first, also, don't name your project with a class name like "DataGrid" which might confuse the compiler

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧