我的C#代码中出现以下错误:
The name 'dgDataGrid' does not exist in the current context
底部的两行是引用它的行:
drDataRow[mbNumCount + 1] = rvRowValue;
}
raDataTable.Rows.Add(drDataRow);
tsseg++;
}
dgDataGrid.DataSource = raDataTable;
dgDataGrid.DataBind();
“design”http://i44.tinypic.com/jhez46.png
的屏幕截图请告诉我,因为我宁愿坚持这个......
Designer.cs代码:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace New_Solution
{
public partial class Default
{
/// <summary>
/// form1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
protected global::System.Web.UI.WebControls.GridView dgDataGrid;
}
}
答案 0 :(得分:1)
问题可能是在designer.cs文件中没有自动添加dgDataGrid。如果是这种情况,请手动将其添加到设计器中。
将这些行添加到default.aspx.designer.cs文件
/// <summary>
/// dgDataGrid control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.GridView dgDataGrid;