Solved

Populating items in a repeater from a class

Posted on 2014-10-16
2
140 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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