?
Solved

Populating items in a repeater from a class

Posted on 2014-10-16
2
Medium Priority
?
151 Views
Last Modified: 2014-10-16
I'm currently populating items in a repeater using the following code:

            Dim myConnectionMenu As New Data.SqlClient.SqlConnection
            Dim myCommandMenu As New Data.SqlClient.SqlCommand
            myConnectionMenu.ConnectionString = myConString
            myCommandMenu.Connection = myConnectionMenu
            Dim ds As New Data.DataSet
            Dim da As New Data.SqlClient.SqlDataAdapter("select * from openquery(myServer,'SELECT MENUTEXT, HREF, HASSUB, SUBID FROM tblMENU WHERE SUBOF=0 ORDER BY MENUORDER')", myConnectionMenu)
            da.Fill(ds, "menuitems")
            rptMenu.DataSource = ds.Tables("menuitems")
            rptMenu.DataBind()

Open in new window


I have a class called basePage in my project. I'd like to run the above code in a routine in that class and call it from multiple pages. Is this possible? How would I go about doing it?

TIA
0
Comment
Question by:Mike Miller
[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
2 Comments
 
LVL 27

Accepted Solution

by:
Sammy Ageil earned 2000 total points
ID: 40385342
Put the code in the Base class constructor or create a private method and call it in the base class constructor
Public Class basePage 
    Sub New() 'Constructor 
        'add your code or the method call here
    End Sub

Open in new window

0
 

Author Comment

by:Mike Miller
ID: 40385353
rptMenu is not declared. It may be inaccessible....
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

718 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