The name 'GridView1' does not exist in the current context - asp.net

I have two files named as TimeSheet.aspx.cs and TimSheet.aspx ,code of the file are given below for your reference.
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.
Im not able to figure out what is causing this issue.Can any one figure whats happen here.
Thanks & Regards,
=======================================
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
=======================================================
<%# Page Language="C#" Theme="Default" MasterPageFile="~/MasterPages/admin.master" AutoEventWireup="true" CodeFile="TimeSheets.aspx.cs" Inherits="TimeSheets" Title="TimeSheets List" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">Time Sheets List</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<data:GridViewSearchPanel ID="GridViewSearchPanel1" runat="server" GridViewControlID="GridView1" PersistenceMethod="Session" />
<br />
<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"
>
<Columns>
<asp:CommandField ShowSelectButton="True" ShowEditButton="True" />
<asp:BoundField DataField="TimeSheetId" HeaderText="Time Sheet Id" SortExpression="[TimeSheetID]" ReadOnly="True" />
<asp:BoundField DataField="TimeSheetTitle" HeaderText="Time Sheet Title" SortExpression="[TimeSheetTitle]" />
<asp:BoundField DataField="StartDate" DataFormatString="{0:d}" HtmlEncode="False" HeaderText="Start Date" SortExpression="[StartDate]" />
<asp:BoundField DataField="EndDate" DataFormatString="{0:d}" HtmlEncode="False" HeaderText="End Date" SortExpression="[EndDate]" />
<asp:BoundField DataField="DateOfCreation" DataFormatString="{0:d}" HtmlEncode="False" HeaderText="Date Of Creation" SortExpression="[DateOfCreation]" />
<data:BoundRadioButtonField DataField="Locked" HeaderText="Locked" SortExpression="[Locked]" />
<asp:BoundField DataField="ReviewedBy" HeaderText="Reviewed By" SortExpression="[ReviewedBy]" />
<data:HyperLinkField HeaderText="Employee Id" DataNavigateUrlFormatString="EmployeesEdit.aspx?EmployeeId={0}" DataNavigateUrlFields="EmployeeId" DataContainer="EmployeeIdSource" DataTextField="LastName" />
</Columns>
<EmptyDataTemplate>
<b>No TimeSheets Found!</b>
</EmptyDataTemplate>
</data:EntityGridView>
<asp:GridView ID="GridView2" runat="server">
</asp:GridView>
<br />
<asp:Button runat="server" ID="btnTimeSheets" OnClientClick="javascript:location.href='TimeSheetsEdit.aspx'; return false;" Text="Add New"></asp:Button>
<data:TimeSheetsDataSource ID="TimeSheetsDataSource" runat="server"
SelectMethod="GetPaged"
EnablePaging="True"
EnableSorting="True"
EnableDeepLoad="True"
>
<DeepLoadProperties Method="IncludeChildren" Recursive="False">
<Types>
<data:TimeSheetsProperty Name="Employees"/>
<%--<data:TimeSheetsProperty Name="TimeSheetDetailsCollection" />--%>
</Types>
</DeepLoadProperties>
<Parameters>
<data:CustomParameter Name="WhereClause" Value="" ConvertEmptyStringToNull="false" />
<data:CustomParameter Name="OrderByClause" Value="" ConvertEmptyStringToNull="false" />
<asp:ControlParameter Name="PageIndex" ControlID="GridView1" PropertyName="PageIndex" Type="Int32" />
<asp:ControlParameter Name="PageSize" ControlID="GridView1" PropertyName="PageSize" Type="Int32" />
<data:CustomParameter Name="RecordCount" Value="0" Type="Int32" />
</Parameters>
</data:TimeSheetsDataSource>
</asp:Content>

Problem can be that GridView1 is not automatically added in designer.cs file. If that is case add it in designer manually.

Assuming a WebSite project verify that when building it you do not get Warnings like:
Generation of designer file failed: [Failure Reason]
It seems that you're not registering the custom control EntityGridView. See the Register directive to see how you can do it.

I've had this problem before when I've 'added' an existing file (.aspx + .aspx.cs) to a project and the designer file hasn't updated itself. I've tried many/all of the things written here, but I find that creating a new file, copying the code-front code in, then the code-behind and then rebuilding essentially does the trick. Yes, it's a pain in the * depending on the size of the file(s) you're working with, but this typically happens when I want to quickly test some demo code I've come across (some new project etc.) and throw it into my local VS.

It is nested, so some things don't happen automatically.
You might have to manually add it to the designer, or else (in VB) explicitly use the handles keyword or (in C#) explicitly wire up with "+=" operator.
Make sure all events or explicitly stated in the control mark-up
Since I see you list the event explicitly, I'd check the designer.

I had this same problem in Visual Studio 2010. The design.cs file was correctly generated. I closed Visual Studio, and reopened it. This resolved this issue for me (after much frustration).

I don't know if this will help, but I've been fighting with a similar situation.
The situation: I have included some code from the modified some of the templated asp.net web project into my project - specifically the login markup. For some reason, one of the "UserName" Textbox control refuses to be recognized in the designer. Strangely enough, the "UserNameLabel" control on the next line of markup is recognized:
<%# Page Language="C#" AutoEventWireup="True" CodeBehind="Logon.aspx.cs" MasterPageFile="~/Site.master" Inherits="SimpleWebApp.Logon" %>
<asp:Content ID="LogonRegister" ContentPlaceHolderID="MainContent" runat="server">
<div></div>
<table align="center">
<tr>
<td valign="top">
*<asp:TextBox ID="TextBox1" runat="server" CssClass="textEntry"></asp:TextBox>*
<asp:Login ID="LoginUser" runat="server" EnableViewState="true" RenderOuterTable="false">
<LayoutTemplate>
<span class="failureNotification">
<asp:Literal ID="FailureText" runat="server"></asp:Literal>
</span>
<asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification"/>
<div class="accountInfo">
<fieldset class="login">
<legend>Log In</legend>
<p>
**<asp:Label ID="lblUserNameLabel" runat="server">Username:</asp:Label>**
***<asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>***
</p>
...
What I've tried:
I've restarted VWD 2010,
deleted the designer file and recreated it through converting the page to a web application
changed the name of the Textbox,
deleted and recreated the Textbox.
I decided to experiment a little, and discovered that adding a typical textbox just outside the asp:Login tag is recognized, while adding it just inside that tag leaves it unrecognized in the designer.
Figured this might help myself or someone else to piece together what might be going on.
Anyone have any idea what might cause this behavior around the asp:Login tag?

For closely related answers, visit a slightly similar question, How do you force Visual Studio to regenerate the .designer files for aspx/ascx files?.
#sameer: I'd be interested to hear if you tried to replace CodeFile="TimeSheets.aspx.cs" with CodeBehind="TimeSheets.aspx.cs" before converting the project.

I know this is an old thread, but I just struggled with an issue similar to this. After a couple of days, I figured out that I had a backup copy of the problem page and code behind in my project. I kept getting the error "does not exist in the current context" at compile time on objects placed on the new page, even though intellisense recognized them. I guess VS was getting confused because of the duplicate pages in the default namespace. Once I got rid of the backup, I magically stopped getting the errors.

I had the same problem, none of the solutions worked for me. I figured out without wasting too much time, that many of the ASPX pages in the Admin section were being given the same class name as the entities in the project entity files. Also, each of the pages listed the Entities namespace causing conflicts since after adding the entity namespace in the using directives, there were namespace conflicts. I went through and added "Page" to each of the ASPX page, recompiled and everything worked fine.
I know this thread has already been answered, but I wanted to include this description in case there are others that have this same problem and none of the above solutions worked, to give them something else that might be the issue.
I had 21 pages to change in my project, here is an example using the UserEntity and the Admin/UserEntity.aspx:
in UsersEntity.aspx front side aspx page, changed:
<%# Page Language="C#"
Theme="Default"
MasterPageFile="~/MasterPages/admin.master"
AutoEventWireup="true"
Inherits="UsersEntity"
Title="UsersEntity"
Codebehind="UsersEntity.aspx.cs"
%>
to:
<%# Page Language="C#"
Theme="Default"
MasterPageFile="~/MasterPages/admin.master"
AutoEventWireup="true"
Inherits="UsersEntityPage"
Title="UsersEntity"
Codebehind="UsersEntity.aspx.cs"
%>
in the UsersEntity.aspx.cs code behind, I changed:
public partial class UsersEntity : System.Web.UI.Page
to:
public partial class UsersEntityEntityPage : System.Web.UI.Page
and in the UsersEntity.aspx.designer.cs (Designer Page):
That page got automatically changed when I changed the code behind page to:
public partial class UsersEntityPage {
I did that for each of the other offending pages, which were all of them except for the "Edit" pages.
-- I guess I could have just removed the using directive to the Entity name space, but I really want to be able to have access to that in my pages, plus I think it is ungood for the page classes to have the exact same name as my entity classes. It causes confusion to me to have it like that.

copy the _.aspx file code and paste it on the _.aspx.cs page.
if it is not then import namespaces all the way top.
<%# Page Language="C#" AutoEventWireup="true" %> <%# Import
Namespace="System.Data" %> <%# Import
Namespace="System.Data.SqlClient" %>

I found that there was an incorrect file reference name in the designer.cs file. It was the code filename with a 1 added to the end. I removed the 1 and the code ran without error. Prior to this I deleted and rebuilt the designer file without resolution.

The easiest way is to:
Delete the designer file (YourFilename.aspx.designer.cs)
Select the ASPX file in Solution Explorer
Under Projects menu look for the item "Convert to Web Application" and click on it. Click Yes on the dialog window.
Open up the newly created designer file and make sure the namespace matches the namespace on the primary aspx.cs file (VERY IMPORTANT)
Close the designer file.
Save the solution. Close it and then reopen.

Related

Custom UserControl is not registering in ASP.NET

Update: J0e3gan tried my code in his own project, and it worked fine (with a minor correction), so the problem appears to be with Visual Studio itself, rather than the code or markup. I have tried adding a new UserControl as well, and it was not recognized either. However, VS is recognizing the AjaxControlToolkit that is registered in web.config just fine. [/update]
I'm trying to add a custom UserControl named AdminControls to the site I'm working on, but I keep getting the following error:
Element 'ControlName' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.
I'm running Visual Studio Pro 2013, and the project is a Web Application. I have searched the Web for solutions, mostly here on Stack Overflow, and have tried every one I could find, but have had no luck. There must be something I'm missing.
Here is the markup for AdminControls:
<asp:Table ID="tblAdminControls" runat="server">
<asp:TableRow>
<asp:TableCell style="min-width: 50%;"> </asp:TableCell>
<asp:TableCell style="width: 6em" id="tdCP" runat="server">
<asp:Button Font-Bold="true" Font-Size="Smaller" Font-Overline="false" ID="btnCP"
runat="server" CssClass="Button" Text="Control Panel" />
</asp:TableCell>
<asp:TableCell style="width: 5em">
<asp:Button Font-Bold="true" Font-Size="Smaller" Font-Overline="false" ID="btnLogOut"
runat="server" CssClass="Button" Text="LogOut" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
And here is the codebehind for it:
Public Class AdminControls
Inherits System.Web.UI.UserControl
Private Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
If Request.ServerVariables("SCRIPT_NAME") = "/frmAdminCP.aspx" Then
tdCP.Visible = False
End If
End Sub
Private Sub btnCP_Click(sender As Object, e As EventArgs) Handles btnCP.Click
Response.Redirect("frmAdminCP.aspx", False)
End Sub
Private Sub btnLogOut_Click(sender As Object, e As EventArgs) Handles btnLogOut.Click
Session.RemoveAll()
Session.Abandon()
Response.Redirect("frmLogin.aspx", False)
End Sub
End Class
I've tried registering AdminControls both in the web.config file and on the page. Here's the relevant bits from the web.config file:
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<controls>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
<add tagPrefix="klc" tagName="AdminHeader" src="~/AdminControls.ascx" />
</controls>
</pages>
And last but not least, here's one of the pages I'm trying to put AdminControls in:
<%# Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
EnableEventValidation="false" Inherits="ProjectName.frmAdminCP" CodeBehind="frmAdminCP.aspx.vb" %>
<%# Register TagPrefix="klc" TagName="AdminHeader" Src="~/Controls/AdminControls.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="content">
<h1>Admin <span class="pagetitle">Control Panel</span> </h1>
<klc:AdminHeader runat="server" id="ahControls" />
<div>
<h2>Users</h2>
View Existing Users<br />
Add a New User
<h2>Usage Reports</h2>
View User Activity Report<br />
View Administrative Log
<h2>Project Management</h2>
View Projects<br />
Manage Project Files
</div>
</div>
</asp:Content>
I have attempted every fix I've come across, even if they seemed ridiculous. I've:
Purged the schema cache.
Cleaned and rebuilt the solution.
Restarted Visual Studio.
Restarted my computer.
Moved the file to a subdirectory.
Cut and pasted the code and markup to the same place and resaved the files.
There are no build errors, and the tagPrefix does not appear in the Intellisense auto-complete dropdown.
Can anyone see any errors I've made, or does anyone know of a solution I haven't tried yet? I haven't tried slaughtering a black rooster over my PC yet, but I'm getting close.
Using the code you provided, I successfully included your user control in a page - screenshot below. I was unable to reproduce the error you are getting.
The only error I encountered along the way stemmed from the two different paths you used for AdminControls.ascx:
src="~/AdminControls.ascx" your Web.config excerpt.
Src="~/Controls/AdminControls.ascx" in your (frmAdminCP.aspx) page excerpt.
Once I made the paths consistent (with each other and the scrach web app project I created), AdminControls showed up in frmAdminCP.aspx just fine:
In case it helps you, for my sanity check I simply created a new ASP.NET Web Forms Application project in Visual Studio 2013 targeting .NET 4.0, added a new Web Forms User Control item named AdminControls.ascx, added a new Web Form item named frmAdminCP.aspx, and pasted your code in all the appropriate places.
I understand I'm a bit late to this answer, but I found a solution.
I was experiencing the same issue where I was attempting to register a custom control but Visual Studio wasn't recognizing it. I was able to resolve this by going to Build->Build Page. After VS finished analyzing and building the page, the error/warning I was getting went away.

Email address in a textbox causes PageRequestManagerServerErrorException

I have a multiline textbox within an updatePanel. where a user can enter any notes he requires. If he enters an email address inside angular brackets then when submitting or cancelling I get a PageRequestManagerServerErrorException of 500.
If he enters an email address in these notes as myaddress.xxx.ca without the brackets, then there is no error.
The textbox should allow him to enter anything he wants too, it is really just for his notes.
I have tried to the RequestValidation = "false" in the page directive but this does not work.
Any suggestions would be appreciated.
Bryan
I assume you are using at least .Net 4.0? I did a small example according to your question and noted the same behaviour. Fortunatelly I found a quick solution (even here on Stackoverflow - Allow html in asp.net textboxes).
aspx
<%# Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeFile="commonQuestions.aspx.cs" Inherits="commonQuestions" %>
.....
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server" Height="81px" TextMode="MultiLine" Width="264px"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Send" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
codeBehind
protected void Button1_Click(object sender, EventArgs e)
{
// do something
Debug.WriteLine("Text: " + TextBox1.Text);
}
add to web.config
<httpRuntime requestValidationMode="2.0" />
And here we got a pretty good explanation from MS, refering to changes in ASP.Net 4
As a result, request validation errors might now occur for requests
that previously did not trigger errors. To revert to the behavior of
the ASP.NET 2.0 request validation feature, add the setting (see above)
in the Web.config file:

Why does Page.ParseControl not create control inherited from the correct base class?

I dynamically create a User Control from XML via XSLT. Output is a string with a content like this:
<%# Control Language="C#" AutoEventWireup="true" Inherits="Library.Web.UI.GeneratedFormBase, MyAssembly" %>
<div class="myCssClass">
<asp:TextBox ID="d" runat="server" OnTextChanged="OnTextChanged" />
<asp:Label runat="server" AssociatedControlID="SomeName" AccessKey="n">Label Text</asp:Label>
<asp:TextBox ID="SomeName" runat="server" OnTextChanged="OnTextChanged" />
<asp:Label runat="server" AssociatedControlID="SomeOtherName">Welcome</asp:Label>
<asp:TextBox ID="SomeOtherName" runat="server" OnTextChanged="OnTextChanged" />
<asp:Button ID="OK" runat="server" OnClick="ButtonClick" Text="Save" />
</div>
I now use Page.ParseControl(theGeneratedString) to create this control dynamically.
The type that is declared in Inherits is existing and can be found. If I declare another (i.e. non-existing) type there, a Parser Error Exception is thrown, so I am totally convinced that the parser looks for this type and finds it.
Nevertheless, the Control that is generated from the ParseControl is of type System.Web.UI.Control and not of the control that is stated (and obviously also parsed and located) in the Inherits-declaration.
Why is that and how can I ensure that the control is of the correct type?
Okay, after using a bit reflector it seems obvious why the Control is of the 'wrong' class. So ParseControl is simply the wrong method to do this. The correct one is LoadControl, but to use it I need to provide the generated form via a VirtualPathProvider. So it's a lot more work to get the control to parse correctly, but when using this approach the control is loaded, parsed, compiled and derived from the correct type.

ASP.NET Controls are not coming in Code-behind IntelliSense

I am having an aspx page where I have added one asp.net text box control with ID and RUNAT attribute. But in Code-behind I am not seeing this control's name in the intellisense.
My page directive in aspx is as follows
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyProject_UI._Default" %>
I am using VS 2008. Any idea how to get rid of this?
Try using CodeFile instead of CodeBehind. The latter is a hold-over from .NET 1.1.
Also, make sure the namespaces match up between the markup and the code. Do a test compile to be sure.
I have seen this on occasion when I edit a page. When it happens to me, I close the files and open them again and it seems to fix itself.
This will happen if you are trying to include your control in LayoutTemplate. For example if you are using an asp label in a login control you have converted to a LayoutTemplate.
<asp:Login ID="userLogin" runat="server">
<LayoutTemplate>
<!--Username and password controls-->
<asp:Button ID="btnLogin" CommandName="Login" runat="server" Text="Login" />
<asp:Label ID="lblAlert" runat="server"></asp:Label>
</LayoutTemplate>
So your lblAlert will not show up on the code behind take it out of the layouttemplate or use a loop to find the control within the layout object.
var mylabel = (Label)userLogin.FindControl("lblAlert");

ASP.NET Compile behavior changes depending on page content?

I've been struggling with some issues relating to referencing child controls within a FormView. Another developer wrote an ASPX page that is compiling and working and in that code, he references child controls within a FormView directly as properties of the page object. The page is part of an ASP.NET Web SITE Project (as opposed to a Web Application Project). We decided to convert the project to the Web Application Project model and noticed that these property references now don't compile. The code behind file does not generate the controls within the form view.
While researching that issue (I had a separate post here regarding those problems), I came across something baffling. From all the posts I've read, you should always need to reference child controls within a FormView's template using FindControl -- i.e. it is supposedly not possible to do through a simple generated property regardless of whether you're in the Web Site Project model or the Web Application Project model.
I was puzzled as to how my colleague's code compiled and ran. As I indicated, he is referencing the FormView's contained child controls through simple properties in the page and did not have to resort to FindControl calls. So to get to the bottom of this mystery, I cooked up the shortest example that demonstrates this phenomenon.
What I found was very strange. The code I have here has a ASP:FormView with a few label controls within it's ItemTemplate. One of those labels has the ID MyComment. When the FormView databinds (to the Northwind's Products table), I simply set some text.
using System;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.FormView1.ChangeMode(FormViewMode.ReadOnly);
}
protected void FormView1_DataBound(object sender, EventArgs e) {
MyComment.Text = "Data bound at " + DateTime.Now.ToString();
}
}
This code will not compile because MyComment is not a valid property. Here comes the strange part. If I embed within the FormView's ItemTemplate a TabContainer control from the Ajax Control Toolkit library, the code above does compile and runs correctly.
So the reason my colleague's code is compiling is because of the embedded TabContainer control within the FormView?? Why this should change the behavior of the compiler and the mechanisms by which you can get access to the FormView's child controls is a mystery to me. Incidentally, despite the fact that it compiles cleanly and runs correctly, Intellisense does not see these properties and ReSharper reports them as compile errors (by the red light in the indicator bar).
Here is the markup for the page. Can anyone shed some light on this behavior? Incidentally, I'm not complaining about the fact that ASP.NET creates these properties in this circumstance. (Unfortunately, this happy, but strange, behavior, only seems to apply if the project is a Web Site Project; as a Web Application Project, property accessors don't work within the FormView even with the embedded TabControl).
<!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">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:FormView ID="FormView1" runat="server" DataKeyNames="ProductID" DataSourceID="SqlDataSource1"
OnDataBound="FormView1_DataBound">
<ItemTemplate>
<ajaxToolkit:TabContainer runat="server" ID="TabsItem">
<ajaxToolkit:TabPanel runat="Server" ID="PanelBasicsItem" HeaderText="Basics">
<ContentTemplate>
ProductID:
<asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' />
<br />
ProductName:
<asp:Label ID="ProductNameLabel" runat="server" Text='<%# Bind("ProductName") %>' />
<br />
My Comment:
<asp:Label ID="MyComment" runat="server"></asp:Label>
<br />
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [ProductID], [ProductName] FROM [Alphabetical list of products]">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
When you converted the Web site to a web application, did you check that the partial classes were correctly generated for your aspx files (e.g. there should be a file called "Default.aspx.cs.designer" in your web application, under the Default.aspx and Default.aspx.cs files).
In a web site, these are generated on the fly by the server as your site runs and is compiled (and so don't exist in your project), while in a web application they are created and managed by Visual Studio - if they don't exist, then the code will potentially fail to compile because the objects haven't been instatiated - what is the actual compiler error are you seeing?
By adding a new control to the page after you've converted the project to a web application, you are forcing VS to create the partial class that was missing.

Resources