Solved

What is wrong with this code declaration?

Posted on 2009-04-01
4
320 Views
Last Modified: 2013-12-25
Could someone please tell me why the vbc (2.0 framework) complains that rptLinks is not declared when in fact it is declared in the repeater statement? I get a similar error in VS 2008.
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="Categories.ascx.vb" Inherits="keepsake.Categories1" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<font face="arial" size="2">
	<asp:Repeater ID="rptLinks" Runat="server">
		<ItemTemplate>
			<a href='quinceanera.aspx?cat_id=<%# DataBinder.Eval(Container.DataItem, "cat_id")%>'><%# DataBinder.Eval(Container.DataItem, "cat_name")%></a><br>
		</ItemTemplate>
		<FooterTemplate>
			<br>
		</FooterTemplate>
	</asp:Repeater>
</font>
---------------------------------------------
Imports System.Data.SqlClient
 
 
Namespace keepsake
 
 
    Partial Class Categories1
        Inherits System.Web.UI.UserControl
 
#Region " Web Form Designer Generated Code "
 
        'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
 
        End Sub
 
 
        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub
 
#End Region
 
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If (Not Page.IsPostBack) Then
                Dim objConn As SqlConnection = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString"))
                Dim objCommand As SqlCommand = New SqlCommand
                Dim objReader As SqlDataReader
 
                objCommand.CommandText = "SELECT * FROM Categories ORDER BY cat_name"
 
                objCommand.Connection = objConn
 
                objConn.Open()
                rptLinks.DataSource = objCommand.ExecuteReader
                rptLinks.DataBind()
                objConn.Close()
 
                objCommand.Dispose()
                objCommand = Nothing
 
                objConn.Dispose()
                objConn = Nothing
            End If
        End Sub
 
    End Class
 
End Namespace

Open in new window

0
Comment
Question by:bigmoxy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 9

Expert Comment

by:cdaly33
ID: 24044579
Does it work if you wrap the repeater in <form> tags?

<form id="form1" runat="server">
        <asp:Repeater ID="rptLinks" Runat="server">
                <ItemTemplate>
                        <a href='quinceanera.aspx?cat_id=<%# DataBinder.Eval(Container.DataItem, "cat_id")%>'><%# DataBinder.Eval(Container.DataItem, "cat_name")%></a><br>
                </ItemTemplate>
                <FooterTemplate>
                        <br>
                </FooterTemplate>
        </asp:Repeater>
</form>

Open in new window

0
 

Author Comment

by:bigmoxy
ID: 24044652
No, I get the same error:

c:\websites\quinceaneragallery.com\Categories.ascx.vb(37) : error BC30451: Name
'rptLinks' is not declared.
0
 
LVL 4

Expert Comment

by:y0usuf
ID: 24049463
There's nothing wrong with the declaration. I know VS2008 shows some carzy messages when they are acctually not. Possibility is there might be some other errors in the page. Are you seeing any other errors along with this?
0
 
LVL 18

Accepted Solution

by:
philipjonathan earned 500 total points
ID: 24049873
Try declaring a member variable 'rptLinks' in the class Categories1:

Partial Class Categories1
  Inherits System.Web.UI.UserControl

    Protected rptLinks As Repeater

...

0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month11 days, 17 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question