0

I have a grid that is named grdUserActivity. I'm not sure what the error means.

The name 'grdUserActivity' does not exist in the current context

C#

public partial class frmViewPersonnel : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            // Declares the DataSet
            dsUserActivity myDataSet = new dsUserActivity();

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

            // Sets the DataGrid to the DataSource based on the table
            grdUserActivity.DataSource = myDataSet.Tables["tblUserActivity"];

            // Binds the DataGrid
            grdUserActivity.DataBind();
        }
    }
}

.ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmPersonnel.aspx.cs"      Inherits="frmPersonnel" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
<form id="form1" runat="server">
<div align="center">

</div>
<asp:Panel ID="Panel1" runat="server" Height="250px" HorizontalAlign="Left" 
    Width="300px">
    <asp:Label ID="Label1" runat="server" Text="First Name:" Width="80px"></asp:Label>
    <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
    <br />
    <asp:Label ID="Label2" runat="server" Text="Last Name:" Width="80px"></asp:Label>
    <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
    <br />
    <asp:Label ID="Label3" runat="server" Text="Pay Rate:" Width="80px"></asp:Label>
    <asp:TextBox ID="txtPayRate" runat="server"></asp:TextBox>
    <br />
    <asp:Label ID="Label4" runat="server" Text="Start Date:" Width="80px"></asp:Label>
    <asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>
    <br />
    <asp:Label ID="Label5" runat="server" Text="End Date:" Width="80px"></asp:Label>
    <asp:TextBox ID="txtEndDate" runat="server"></asp:TextBox>
    <br />
    <asp:Button ID="btnSubmit" runat="server" 
        PostBackUrl="~/frmPersonnalVerified.aspx" Text="Submit" 
        onclick="btnSubmit_Click" />
    <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
    <br />
    <asp:Label ID="lblError" runat="server"></asp:Label>
</asp:Panel>
</form>

Tim B James
  • 20,084
  • 4
  • 73
  • 103
Mike
  • 2,293
  • 13
  • 42
  • 56

1 Answers1

1

Not sure if this is a type-o

But your aspx file is pointing to frmUserActivity rather than frmViewPersonnel

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmUserActivity.aspx.cs" Inherits="frmUserActivity" %>

So either you are editing the wrong .cs file, OR the wrong .aspx file ;)

EDIT

After seeing your edits, your frmUserAcitivty aspx page does not contain the grdUserActivity control. So of course it wont be found.

Tim B James
  • 20,084
  • 4
  • 73
  • 103