Solved

Populating items in a repeater from a class

Posted on 2014-10-16
2
146 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
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:Mike Miller
ID: 40385353
rptMenu is not declared. It may be inaccessible....
0

Featured Post

Independent Software Vendors: 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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 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