.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Imran Ghani
Post New Web Links

Repeater Control Does not exist in current context, but other controls do

Posted By:      Posted Date: October 04, 2010    Points: 0   Category :ASP.Net
 

I have an aspx page containing a number of asp:Repeater Controls.

Im not using the default code-behind file that is generated, ive changed this to file in a different folder.


In the code-behind, i populate the repeater controls, all was workign fine until i added another repeater control to the aspx page.
In the code-behind, the intellisense picks up this control and i can access its methods and properties to set the datasource and bind the data. However, when i go to build the project, i get an error "The name Repeater1 does not exist in the current context"

Firstly, all the other repeater controls, declared in exactly the same way, do not throw throw this error.
Secondly, yes the repeater does have a runat="server" tag.
Thirdly, It is not inside any other controls.


I have tried various different methods of accessing this repater instead of just "Repeater1." but each returns null:

Repeater r1 = (Repeater)Page.FindControl("Repeater1") ;
Repeater r1 = (Repeater)Page.Master.FindControl("Repeater1"); 
Repeater r1 = (Repeater)Master.FindControl("Repeater1") ;

Ive no idea why this "doesnt exist in the current context" as all the other controls on this page do, even if i create a literal i get the same problem


View Complete Post


More Related Resource Links

Login control - Controls do not exist in current context

  
Hi all,Trying to set up the Login control as a User control, but none of the controls exist in the current context?None of my code below is recognised? What's going on here please? I've rebuilt the solution many times.if (Membership.ValidateUser(this.UserName.Text, this.Password.Text))        {            FormsAuthentication.RedirectFromLoginPage(UserName.Text, RememberMe.Checked);        }        else        {             Msg.Text = "Login failed. Please check your user name and password and try again.";        }

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

  

Hey i have a Class named Helper.cs inside my App_Code folder.

And i get this error:

Compilation Error



Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0103: The name 'Helper' does not exist in the current context

Source Error:

Line 26:         {
Line 27:             SqlConnection con = new SqlConnection(Helper.ConnectionString());


The name 'User' does not exist in the current context.

  

Hey guys,

I've got a literal control to display the username of the user logged into our companies intranet system, originally I had a LoginName control but couldn't get strip to remove the domain from the username (as the format is domainname\username) so I'm trying it this way.

    protected void Page_Load(object sender, System.EventArgs e)
    {
        string[] Parts = User.Identity.Name.Split("\\");

        if (Parts.Length == 2)
        {
            loginName.Text = Parts[1];
        }
        else
        {
            loginName.Text = User.Identity.Name;
        }

    }


    protected void Page_Load(object sender, System.EventArgs e)
    {
        string[] Parts = User.Identity.Name.Split("\\");

The name 'InitializeComponent' does not exist in the current context

  
Hello!I'm creating  a control library and consequently a class.Visual studio compiler is giving my followed error, when I wrote InitializeComponent();The name 'InitializeComponent' does not exist in the current contextCan anybody help me please?

Compiler Error Message: CS0103: The name 'lblRegion' does not exist in the current context

  
i am gettign this error Compiler Error Message: CS0103: The name 'lblRegion' does not exist in the current context Source Error: Line 31: {Line 32: Line 33: lblRegion.Text = dt.Rows[0]["RegionName"].ToString();Line 34: lblCountry.Text = dt.Rows[0]["CountryName"].ToString();Line 35: lblCountryCode.Text = dt.Rows[0]["CountryCode"].ToString(); this is source code:using System;using System.Data;using System.Configuration;using System.Collections;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 System.Net;using System.Xml;public partial class CSharp : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        //Get IP Address        string ipaddress;        ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];        if (ipaddress == "" || ipaddress == null)            ipaddress = Request.ServerV

The name 'id' does not exist in the current context

  

        int Id = Convert.ToInt32(ddlCardDetails.SelectedValue.Split('|')[0]);
        tbl_Payment democustomer = ctx.tbl_Payments.SingleOrDefault(c => c.ID == id);

 

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'id' does not exist in the current context

Source Error:


Line 523:
Line 524:        int Id = Convert.ToInt32(ddlCardDetails.SelectedValue.Split('|')[0]);
Line 525:        tbl_Payment democustomer = ctx.tbl_Payments.SingleOrDefault(c => c.ID == id);
Line 526:
Line 527:


The name 'Profile' does not exist in the current context

  

So, I'm using the .NET 2.0 Profile object to manage custom user data on an internal site for my company. Everything seems to be working flawlessly until I realized I was going to have to add a redundant block of code to every aspx page in order to take advantage of the Profile.

At this point I decided to create a custom base page that could be inherited by all of my aspx pages. Seemed like the right idea, until I got the above error:

 

The name 'Profile' does not exist in the current context

 

I might be missing out on how/when the Profile object is getting built but I was wondering if anyone had any suggestions on how to access the Profile object from a base page/class.


'Session' does not exist in the current context

  

In my application I am trying to read and write session variables in a class file using C#.  What do I need to use to access the Session variables?


The name 'PopularApplicationSkins' does not exist in the current context for Ribbon.

  

Hi, when i want to set Office2007 style to my Ribbon, throw an exception and say:

The name 'PopularApplicationSkins' does not exist in the current context !

what should i do?

Thanks


Amin Mashayekhi

Label does not exist in the current context error

  

Hello All,

I am facing a weird issue.I have a label on the front end but when I try to use it on the code-behind and run my code I obtain an error: Label does not exist in the current context! The label is shown in intellisense and was working earlier.My team mate had created a back up of the file and it stopped working after that.I deleted the back up files and tried but it doesn't seem to work.Any suggestions will be greatly appreciated.


The following is the code snippet of the front end as well as the code behind:


 <div id="weather">
     <img src="sunny.jpg" alt="sunny" height="40px" width="40px"/>
     <h3>Weather</h3>
     <p><i>(5 minute Averages)</i></p>
     <table>
      <tr>
            <td><b><font size="2px">Current Time</font></b></td>
            <td><asp:Label runat="server" ID="Label_Time"></asp:Label></td>
       </tr>
       <tr><td><b><font size="2px">Temperature</font></b></td><td><asp:Label runat="server" ID="Label_Temperature"></asp:Label></td>
       </tr>
    

Problems with Repeater Control, Update Panel and the Toolkit controls

  

Hi Guys,

 

Having a bit of an issue with the Toolkit controls.

I have a Repeater Control nested inside the Update panel, the repeater item template contains a multiview control allowing users to flick through seperate bits of information. This was working fine the async update was perfect, no issues.

I have then decided to include the rating control to one of the views. problem is now everytime i want to change the view it causes the whole page to postback.  

Attached is the code.

Any help is much appreciated


The name xxx Does Not Exist in the Current Context

  

I add a label to a page and set its ID to LabelEditMessage and debug, and there it is.  Then in the code behind page (C#) I add a line of code LabelEditMessage.Text="test";  If I build, the build succeeds, but if I press the debug button it does another build that fails and tells me that LabelEditMessage Does Not Exist in the Current Context.  Intellisense knows about it, and I use that to enter the reference to be sure I am not mispelling. 

So I tried using FindControl, and that fails with a null reference.  It is there, I can see it, but Visual Web Developer refuses to acknowledge it's existence in the code behind file.  If I remove the code reference it builds fine and I can see the label with its default value when i debug, but I cannot reference the label in code.

I'm stumped.  It's such a simple thing that I have done many times before.  I just don't know what else to try.

I had an almost identical problem once before in the page load event trying to set the ConnectionString property of an SqlDataSource.  I tried everything I could think of for days.  Then one day I deleted a validator element and it suddenly started working, and I replaced the validator and it kept on working, so I dismissed it as a fluke.  But now it is back, only this time with a label rather than an SqlDataSource. 

cmd does not exist in current context

  

Ok Guys and Gals

I am having a problem and yes I don't know what I am doing :)


I need to have a calendar control or really any control i use set a parm to the selected or entered value. I have done some reading and I thought I found the answer but I am getting cmd does not exist in current context asp.net


page load 


            string RequestDate = "Blah"; 
  

      protected void CalendarRequestDate_SelectionChanged(object sender, EventArgs e)
        {

            cmd.Parameters.AddWithValue("@RequestDate", CalendarRequestDate.SelectedDate.ToShortDateString());
            LabelRequestDate.Text = @RequestDate;

        }



CS0103 The Name 'Layout' does not exist in the current context

  

Hi,

I am working on WebMatrix Samples on using Layout and Razor Syntaxe. Unfortunatly I have an CS0103 Server error when a run the site that says that "The name 'Layout' does not exist inthe current context.

The sample is very easy. Two files, Index.cshtml and _Layout.cshtml in the same directory.

The "_Layout.cshtml" content is:
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>My WebSite</title>
    </head>
    <body>
        @RenderBody()
    </body>
</html>

And the "index.cshtml" centent is:
@{
    Layout = "~/_Layout.cshtml";
    }

<h1>Hello World!</h1>
<h2>Hello World!</h2>
<h3>Hello World!</h3>

 The error occurse on the line 2 of the index.cshtml file.

I tred to use Layout = "_Layout.cshtml" but without success. So can you please help me with this issue.

For information :


The name 'intPageID' does not exist in the current context

  

Hi all,

In my web app i call C# function inside javascript

function DeletePage(intPageID) {
            alert(intPageID);
            document.getElementById("ctl00_ContentPlaceHolder1_hdnPageID").value = intPageID;
            if (confirm("Are you sure you want to delete selected file?")) {
            alert(document.getElementById("ctl00_ContentPlaceHolder1_hdnPageID").value);
               <% DeleteData(intPageID); %>
                window.location.href = "MiniSite_Pages.aspx";
            }
        }

in code behind

 public void DeleteData(int intPageID)
    {
        MiniSitePagesService objMiniSitePagesService = new MiniSitePagesService();
        objMiniSitePagesService.Delete(intPageID);
    }

but i have error 'The name 'intPageID' does not exist in the current context'

can anyone help me please?

Thanks in advance.


Accessing the different controls inside a GridView control

  
how we can access a particular control which resides inside a GridView control. In this article I will show you how you can access different controls inside a GridView control. We will see how we can access a TextBox control, a DropDownList control and a ListBox control. If you are working with ASP.NET 1.X then you might want to check out my article Accessing Different Controls Inside a DataGrid.

ASP.NET repeater control - databind with style

  
even used the inline editing features, which I at the time thought was the coolest way possible to write ASP.NET code ( I managed to write code to hide all other rows and only show the current one - the row being edited). With a nice looking EditTemplate it looked indeed very slick but it really turned into giant and hard to manage code behind files.
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend