2011-11-14 101 views
0

我得到這個錯誤: 「grdViewPersonnel」這個名字不會在目前情況下存在「grdViewPersonnel」這個名字不會在目前情況下存在

public partial class frmViewPersonnel : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     if (!Page.IsPostBack) 
     { 

      // Declare the DataSet 
      dsPersonnel myDataSet = new dsPersonnel(); 

      // Fill the dataset with what is returned from the function 
      myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb")); 

      // Set the DataGrid to the DataSource based on the table 
      grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"]; 

      // Bind the DataGrid 
      grdViewPersonnel.DataBind(); 
     } 
    } 
} 
+2

您的.aspx文件是否有一個名爲'grdViewPersonnel'的GridView對象? – drdwilcox

+0

@drdwilcox:謝謝,我知道這很簡單。 – Mike

回答

3

我敢打賭,錯誤ISN」在這裏發生?也許在designer.cs文件中?

0

檢查您的代碼,如果您的GridView真的名爲grdViewPersonnel。也許你打錯了或稍後宣佈。

0

您是否檢查過設計器頁面中的gridview實際上是否被命名爲grdViewPersonnel

相關問題