Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

What is wrong with this code declaration?

Posted on 2009-04-01
4
Medium Priority
?
322 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 2000 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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

705 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