Solved

Populating items in a repeater from a class

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

617 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