473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to resolve The name 'Label1' does not exist in the current context error?

Hi

Firts I apoogize if this in the wromng place.

I am new to asp.net and have no IT trainining. I am a volunteer attempting to redevelop a site previously developed in Front Page and classic asp for a non-profit organization.

I am getting "The name 'Label1' does not exist in the current context" errors

The code getting this error follows:
Expand|Select|Wrap|Line Numbers
  1. <script runat="server" language="C#">
  2. protected override void OnLoad(EventArgs e)
  3. {
  4.  
  5.     base.OnLoad(e);
  6. SqlDataSource1.SelectParameters["Type"].DefaultValue = (string)Session["Type"];
  7.  SqlDataSource1.SelectParameters["Sys"].DefaultValue = (string)Session["Sys"];  
  8.       SqlDataSource1.SelectParameters["Level"].DefaultValue = (string)Session["Level"];
  9.        SqlDataSource1.SelectParameters["Split"].DefaultValue = (string)Session["Split"];  
  10.           SqlDataSource1.SelectParameters["Fname"].DefaultValue = (string)Session["Fname"];   
  11.             SqlDataSource1.SelectParameters["MI"].DefaultValue = (string)Session["MI"];
  12.              SqlDataSource1.SelectParameters["Lname"].DefaultValue = (string)Session["Lname"];  
  13.                SqlDataSource1.SelectParameters["Email"].DefaultValue = (string)Session["Email"];   
  14.                  SqlDataSource1.SelectParameters["Address"].DefaultValue = (string)Session["Address"]; 
  15.                  SqlDataSource1.SelectParameters["City"].DefaultValue = (string)Session["City"];    
  16.                   SqlDataSource1.SelectParameters["State"].DefaultValue = (string)Session["State"];   
  17.                    SqlDataSource1.SelectParameters["Zip"].DefaultValue = (string)Session["Zip"]; 
  18.                    SqlDataSource1.SelectParameters["Hphone"].DefaultValue = (string)Session["Hphone"]; 
  19.                        SqlDataSource1.SelectParameters["Cphone"].DefaultValue = (string)Session["Cphone"]; 
  20.                            SqlDataSource1.SelectParameters["Sex"].DefaultValue = (string)Session["Sex"];
  21.                             SqlDataSource1.SelectParameters["Race"].DefaultValue = (string)Session["Race"];  
  22.                                SqlDataSource1.SelectParameters["Mnth"].DefaultValue = (string)Session["Mnth"];   
  23.                                  SqlDataSource1.SelectParameters["Dy"].DefaultValue = (string)Session["Dy"];
  24.                                   SqlDataSource1.SelectParameters["Yr"].DefaultValue = (string)Session["Yr"];    
  25.                                    SqlDataSource1.SelectParameters["Dlic"].DefaultValue = (string)Session["Dlic"]; 
  26.                                        SqlDataSource1.SelectParameters["State2"].DefaultValue = (string)Session["State2"]; 
  27.                                        SqlDataSource1.SelectParameters["pt1"].DefaultValue = (string)Session["pt1"];   
  28.                                          SqlDataSource1.SelectParameters["pt2"].DefaultValue = (string)Session["pt2"];  
  29.                                             SqlDataSource1.SelectParameters["pt3"].DefaultValue = (string)Session["pt3"];
  30.                                               SqlDataSource1.SelectParameters["Alias"].DefaultValue = (string)Session["Alias"];  
  31.                                                 SqlDataSource1.SelectParameters["Certify"].DefaultValue = (string)Session["Certify"];   
  32.                                                   SqlDataSource1.SelectParameters["CofC"].DefaultValue = (string)Session["CofC"];
  33.                                                    SqlDataSource1.SelectParameters["GuidPrinc"].DefaultValue = (string)Session["GuidPrinc"];
  34.                                                    SqlDataSource1.SelectParameters["ConCus"].DefaultValue = (string)Session["ConCus"];
  35.  
  36.                                                    Label1.Text = (string)Session["Type"];
  37.                                                    Label2.Text = (string)Session["Sys"];
  38.                                                    Label3.Text = (string)Session["Level"];
  39.                                                    Label4.Text = (string)Session["Split"];
  40.                                                    Label5.Text = (string)Session["Fname"];
  41.                                                    Label6.Text = (string)Session["MI"];
  42.                                                    Label7.Text = (string)Session["Lname"];
  43.                                                    Label8.Text = (string)Session["Email"];
  44.                                                    Label9.Text = (string)Session["Address"];
  45.                                                    Label10.Text = (string)Session["City"];
  46.                                                    Label11.Text = (string)Session["State"];
  47.                                                    Label12.Text = (string)Session["Zip"];
  48.                                                    Label13.Text = (string)Session["Hphone"];
  49.                                                    Label14.Text = (string)Session["Cphone"];
  50.                                                    Label15.Text = (string)Session["Sex"];
  51.                                                    Label16.Text = (string)Session["Race"];
  52.                                                    Label17.Text = (string)Session["Mnth"];
  53.                                                    Label18.Text = (string)Session["Dy"];
  54.                                                    Label19.Text = (string)Session["Yr"];
  55.                                                    Label20.Text = (string)Session["Dlic"];
  56.                                                    Label21.Text = (string)Session["State2"];
  57.                                                    Label22.Text = (string)Session["pt1"];
  58.                                                    Label23.Text = (string)Session["pt2"];
  59.                                                    Label24.Text = (string)Session["pt3"];
  60.                                                    Label25.Text = (string)Session["Alias"];
  61.                                                    Label26.Text = (string)Session["Certify"];
  62.                                                    Label27.Text = (string)Session["cofc"];
  63.                                                    Label28.Text = (string)Session["GuidPrinc"];
  64.                                                    Label29.Text = (string)Session["ConCus"]; 
  65.  
  66.  
  67.  
  68.    }
  69. </script>
  70.  
I can see in Visual Studio, the same problem exiist for labels 11 and 18 -24.

I woulkd humbly appreciate any help I can get. Thank you in advance Billie
Jan 26 '11 #1
1 5023
My best guess would be that all of the labels used to display the data from the database have been renamed on the page. What you'll probably need to do it go through them all and rename them here in this code to whatever their new names are. For example, in the case of "Label1", you'll need to go to the page and identify which label is supposed to show the value of the data field "Type" from the database. See what that label's new name is, and change "Label1" in your code above to be that new name. Then rinse and repeat...
Jan 26 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: CuriousGeorge | last post by:
I've upgraded a .Net 1.1 web app to 2.0 and am having a heck of a time getting resources to work again. From what I understand if I move my strings.resx file into the App_GlobalResources folder I...
2
by: Jeff | last post by:
hey asp.net 2.0 (C'#) In the code behind file I have this method: public String AddBR(Object param) { String text = (String) param; return text; }
3
by: Michael | last post by:
Hi, I am getting a strange error. Last night when I left work this was working perfectly. This morning when I try to run this code in VS2005, it comes up with an error saying "The name 'UserName'...
4
by: techguy78 | last post by:
Hi - I added a gridview to me aspx page and i 'm trying to assing data to it from codebehind. i'm getting this error.. The name 'Gridview1' does not exist in the current context Any idea...
5
by: nudrat | last post by:
I included a control TextBox with 'txtError' name. whenever I build this I get this error. The name 'txtError' does not exist in the current context But its running on last successful Build. I...
0
by: Dave | last post by:
I have an ASPX page that I can't seem to do anything with the dropdowns. The error that I'm getting is "The name 'EmployeeDropdownList' does not exist in the current context. I have all the...
2
by: =?Utf-8?B?QyNub3ZpY2U=?= | last post by:
Like my name says I am a total novice at C#. I am trying to following examples in a book that I have but unfortunately they do not provide you with code for the whole project. Up till now I could...
1
by: avecreep | last post by:
Hi, i was trying to find a web application and i found one open source on the internet. i put the code folders on the root folder and when i tried to acces via web browser it all worked fine ( i...
0
by: Terry | last post by:
Hello, I have problem adding controls to my webpage default.aspx. There is a group of controls that just refuse to be used with message: 'The name 'controlname' does not exist in the current...
6
by: cbellew | last post by:
G'day, I have encontered what appears to be a common problem, but unfortunately the typical solution i have found has not worked for me. I have just copied the files from an "ASP .NET Web Site"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.