Solved

Populating items in a repeater from a class

Posted on 2014-10-16
2
142 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:mwmiller78
2 Comments
 
LVL 27

Accepted Solution

by:
Sammy earned 500 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:mwmiller78
ID: 40385353
rptMenu is not declared. It may be inaccessible....
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now