Solved

What is wrong with this code declaration?

Posted on 2009-04-01
4
317 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

738 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