title: The name 'GridView1' does not exist in the current context
body: <p>I have two files named as TimeSheet.aspx.cs and TimSheet.aspx ,code of the file are given below for your reference.</p>
  
  <p>when i build the application im getting error "The name 'GridView1' does not exist in the current context" even thought i have a control with the id GridView1 and i have added the runat="server" as well.</p>
  
  <p>Im not able to figure out what is causing this issue.Can any one figure whats happen here.</p>
  
  <p>Thanks &amp; Regards,</p>
  
  <pre><code>=======================================
  TimeSheet.aspx.cs 
  =======================================
  #region Using directives
  using System;
  using System.Data;
  using System.Configuration;
  using System.Web;
  using System.Web.Security;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;
  using System.Web.UI.HtmlControls;
  using TSMS.Web.UI;
  #endregion
  
  public partial class TimeSheets: Page
  {   
      protected void Page_Load(object sender, EventArgs e)
      {
  
          FormUtil.RedirectAfterUpdate(GridView1, "TimeSheets.aspx?page={0}");
          FormUtil.SetPageIndex(GridView1, "page");
          FormUtil.SetDefaultButton((Button)GridViewSearchPanel1.FindControl("cmdSearch"));
      }
  
      protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
      {
          string urlParams = string.Format("TimeSheetId={0}", GridView1.SelectedDataKey.Values[0]);
          Response.Redirect("TimeSheetsEdit.aspx?" + urlParams, true);
      }
  
      protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) {
  
  
      }
  }
  =======================================================
  TimeSheet.aspx
  =======================================================
  &lt;%@ Page Language="C#" Theme="Default" MasterPageFile="~/MasterPages/admin.master" AutoEventWireup="true"  CodeFile="TimeSheets.aspx.cs" Inherits="TimeSheets" Title="TimeSheets List" %&gt;
  
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server"&gt;Time Sheets List&lt;/asp:Content&gt;
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"&gt;
          &lt;data:GridViewSearchPanel ID="GridViewSearchPanel1" runat="server" GridViewControlID="GridView1" PersistenceMethod="Session" /&gt;
          &lt;br /&gt;
          &lt;data:EntityGridView ID="GridView1" runat="server"          
                  AutoGenerateColumns="False"                 
                  OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
                  DataSourceID="TimeSheetsDataSource"
                  DataKeyNames="TimeSheetId"
                  AllowMultiColumnSorting="false"
                  DefaultSortColumnName="" 
                  DefaultSortDirection="Ascending"    
                  ExcelExportFileName="Export_TimeSheets.xls" onrowcommand="GridView1_RowCommand"         
              &gt;
              &lt;Columns&gt;
                  &lt;asp:CommandField ShowSelectButton="True" ShowEditButton="True" /&gt;              
                  &lt;asp:BoundField DataField="TimeSheetId" HeaderText="Time Sheet Id" SortExpression="[TimeSheetID]" ReadOnly="True" /&gt;
                  &lt;asp:BoundField DataField="TimeSheetTitle" HeaderText="Time Sheet Title" SortExpression="[TimeSheetTitle]"  /&gt;
                  &lt;asp:BoundField DataField="StartDate" DataFormatString="{0:d}" HtmlEncode="False" HeaderText="Start Date" SortExpression="[StartDate]"  /&gt;
                  &lt;asp:BoundField DataField="EndDate" DataFormatString="{0:d}" HtmlEncode="False" HeaderText="End Date" SortExpression="[EndDate]"  /&gt;
                  &lt;asp:BoundField DataField="DateOfCreation" DataFormatString="{0:d}" HtmlEncode="False" HeaderText="Date Of Creation" SortExpression="[DateOfCreation]"  /&gt;
                  &lt;data:BoundRadioButtonField DataField="Locked" HeaderText="Locked" SortExpression="[Locked]"  /&gt;
                  &lt;asp:BoundField DataField="ReviewedBy" HeaderText="Reviewed By" SortExpression="[ReviewedBy]"  /&gt;
                  &lt;data:HyperLinkField HeaderText="Employee Id" DataNavigateUrlFormatString="EmployeesEdit.aspx?EmployeeId={0}" DataNavigateUrlFields="EmployeeId" DataContainer="EmployeeIdSource" DataTextField="LastName" /&gt;
  
              &lt;/Columns&gt;
              &lt;EmptyDataTemplate&gt;
                  &lt;b&gt;No TimeSheets Found!&lt;/b&gt;
              &lt;/EmptyDataTemplate&gt;
          &lt;/data:EntityGridView&gt;
          &lt;asp:GridView ID="GridView2" runat="server"&gt;
      &lt;/asp:GridView&gt;
          &lt;br /&gt;
          &lt;asp:Button runat="server" ID="btnTimeSheets" OnClientClick="javascript:location.href='TimeSheetsEdit.aspx'; return false;" Text="Add New"&gt;&lt;/asp:Button&gt;
          &lt;data:TimeSheetsDataSource ID="TimeSheetsDataSource" runat="server"
              SelectMethod="GetPaged"
              EnablePaging="True"
              EnableSorting="True"
              EnableDeepLoad="True"
              &gt;
              &lt;DeepLoadProperties Method="IncludeChildren" Recursive="False"&gt;
                  &lt;Types&gt;
                      &lt;data:TimeSheetsProperty Name="Employees"/&gt; 
                      &lt;%--&lt;data:TimeSheetsProperty Name="TimeSheetDetailsCollection" /&gt;--%&gt;
                  &lt;/Types&gt;
              &lt;/DeepLoadProperties&gt;
              &lt;Parameters&gt;
                  &lt;data:CustomParameter Name="WhereClause" Value="" ConvertEmptyStringToNull="false" /&gt;
                  &lt;data:CustomParameter Name="OrderByClause" Value="" ConvertEmptyStringToNull="false" /&gt;
                  &lt;asp:ControlParameter Name="PageIndex" ControlID="GridView1" PropertyName="PageIndex" Type="Int32" /&gt;
                  &lt;asp:ControlParameter Name="PageSize" ControlID="GridView1" PropertyName="PageSize" Type="Int32" /&gt;
                  &lt;data:CustomParameter Name="RecordCount" Value="0" Type="Int32" /&gt;
              &lt;/Parameters&gt;
          &lt;/data:TimeSheetsDataSource&gt;
  
  &lt;/asp:Content&gt;
  </code></pre>