CS0103: The name 'rGrid' does not exist in the current context

2.1k Views Asked by At

I have an ASPX Page:

<%@ Page Language="C#" MasterPageFile="~/site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="myProject.Presentation.Web.Default" src="Default.aspx.cs" %>
<%@ MasterType VirtualPath="~/site.Master" %>

...

<asp:Repeater ID="rGrid" runat="server">
 <ItemTemplate>
  ...
 </ItemTemplate>
</asp:Repeater>

With this Master:

<%@ Master Language="C#" AutoEventWireup="true" Codebehind="site.master.cs" Inherits="myProject.Presentation.Web.master" src="~/site.Master.cs" %>

When I try to access one of the members on the page:

namespace myProject.Presentation.Web {
public partial class Default : System.Web.UI.Page
     ...
     rGrid.DataSource = myProject.Business.User.GetReports(UserId, true);

I get this YSOD on that line:

CS0103: The name 'rGrid' does not exist in the current context

Yet Intellisense and Object Exporer say it's valid. Why is that?

3

There are 3 best solutions below

1
On BEST ANSWER

Is this a website or web app?

If it's a web app, delete your designer files, then right click on your aspx page and/or master page and select convert to web app. This will rebuild the designer files.

0
On

This is nonsense, canned the project and redoing it as a website project.

0
On

This error generally occurs when variable declerations and variable usage are in different scopes. Check *.aspx.cs file and designer file namespace , namespaces must be same..