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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Billie Hartline
    New Member
    • Jan 2011
    • 7

    #1

    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:
    Code:
    <script runat="server" language="C#">
    protected override void OnLoad(EventArgs e)
    {
    
        base.OnLoad(e);
    SqlDataSource1.SelectParameters["Type"].DefaultValue = (string)Session["Type"];
     SqlDataSource1.SelectParameters["Sys"].DefaultValue = (string)Session["Sys"];  
          SqlDataSource1.SelectParameters["Level"].DefaultValue = (string)Session["Level"];
           SqlDataSource1.SelectParameters["Split"].DefaultValue = (string)Session["Split"];  
              SqlDataSource1.SelectParameters["Fname"].DefaultValue = (string)Session["Fname"];   
                SqlDataSource1.SelectParameters["MI"].DefaultValue = (string)Session["MI"];
                 SqlDataSource1.SelectParameters["Lname"].DefaultValue = (string)Session["Lname"];  
                   SqlDataSource1.SelectParameters["Email"].DefaultValue = (string)Session["Email"];   
                     SqlDataSource1.SelectParameters["Address"].DefaultValue = (string)Session["Address"]; 
                     SqlDataSource1.SelectParameters["City"].DefaultValue = (string)Session["City"];    
                      SqlDataSource1.SelectParameters["State"].DefaultValue = (string)Session["State"];   
                       SqlDataSource1.SelectParameters["Zip"].DefaultValue = (string)Session["Zip"]; 
                       SqlDataSource1.SelectParameters["Hphone"].DefaultValue = (string)Session["Hphone"]; 
                           SqlDataSource1.SelectParameters["Cphone"].DefaultValue = (string)Session["Cphone"]; 
                               SqlDataSource1.SelectParameters["Sex"].DefaultValue = (string)Session["Sex"];
                                SqlDataSource1.SelectParameters["Race"].DefaultValue = (string)Session["Race"];  
                                   SqlDataSource1.SelectParameters["Mnth"].DefaultValue = (string)Session["Mnth"];   
                                     SqlDataSource1.SelectParameters["Dy"].DefaultValue = (string)Session["Dy"];
                                      SqlDataSource1.SelectParameters["Yr"].DefaultValue = (string)Session["Yr"];    
                                       SqlDataSource1.SelectParameters["Dlic"].DefaultValue = (string)Session["Dlic"]; 
                                           SqlDataSource1.SelectParameters["State2"].DefaultValue = (string)Session["State2"]; 
                                           SqlDataSource1.SelectParameters["pt1"].DefaultValue = (string)Session["pt1"];   
                                             SqlDataSource1.SelectParameters["pt2"].DefaultValue = (string)Session["pt2"];  
                                                SqlDataSource1.SelectParameters["pt3"].DefaultValue = (string)Session["pt3"];
                                                  SqlDataSource1.SelectParameters["Alias"].DefaultValue = (string)Session["Alias"];  
                                                    SqlDataSource1.SelectParameters["Certify"].DefaultValue = (string)Session["Certify"];   
                                                      SqlDataSource1.SelectParameters["CofC"].DefaultValue = (string)Session["CofC"];
                                                       SqlDataSource1.SelectParameters["GuidPrinc"].DefaultValue = (string)Session["GuidPrinc"];
                                                       SqlDataSource1.SelectParameters["ConCus"].DefaultValue = (string)Session["ConCus"];
    
                                                       Label1.Text = (string)Session["Type"];
                                                       Label2.Text = (string)Session["Sys"];
                                                       Label3.Text = (string)Session["Level"];
                                                       Label4.Text = (string)Session["Split"];
                                                       Label5.Text = (string)Session["Fname"];
                                                       Label6.Text = (string)Session["MI"];
                                                       Label7.Text = (string)Session["Lname"];
                                                       Label8.Text = (string)Session["Email"];
                                                       Label9.Text = (string)Session["Address"];
                                                       Label10.Text = (string)Session["City"];
                                                       Label11.Text = (string)Session["State"];
                                                       Label12.Text = (string)Session["Zip"];
                                                       Label13.Text = (string)Session["Hphone"];
                                                       Label14.Text = (string)Session["Cphone"];
                                                       Label15.Text = (string)Session["Sex"];
                                                       Label16.Text = (string)Session["Race"];
                                                       Label17.Text = (string)Session["Mnth"];
                                                       Label18.Text = (string)Session["Dy"];
                                                       Label19.Text = (string)Session["Yr"];
                                                       Label20.Text = (string)Session["Dlic"];
                                                       Label21.Text = (string)Session["State2"];
                                                       Label22.Text = (string)Session["pt1"];
                                                       Label23.Text = (string)Session["pt2"];
                                                       Label24.Text = (string)Session["pt3"];
                                                       Label25.Text = (string)Session["Alias"];
                                                       Label26.Text = (string)Session["Certify"];
                                                       Label27.Text = (string)Session["cofc"];
                                                       Label28.Text = (string)Session["GuidPrinc"];
                                                       Label29.Text = (string)Session["ConCus"]; 
                                                     
      
    
       }
    </script>
    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
  • bentleyw
    New Member
    • Feb 2008
    • 32

    #2
    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...

    Comment

    Working...