How to populate a asp:Repeater from a base class?

S

sonicm

Hi,

What is the best way of populating a repeater control from a SQL Database
using a base class. I am trying to impliment a base class that can be used
across future websites and will populate a repeater control on the aspx page.

The logic is losing me a bit as it seems wrong to try to access the control
from a base class but I can't seem to get the base class to work correctly
unless I copy all the html code into the base class and write it out which
also seems wrong?

Any help would be appreciated?
Thanks.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,



Usually the repeater's content is declared in the aspx page. I have never
seen it done othewise.

I do not understand what you mean with a "base class", could you explain
further?
 
S

sonicm

Hi,

Yes sorry, I am (cough for an exam) creating a web page, that needs to show
some data from SQL. However, part of it is that similar pages in the future
will need to show the data in the future. So I have created a base class to
come off the main aspx page.

The only problem is that I don't know how to show the data on the aspx page
from the base class as it cannot see any of the controls on the main page?

So:

page1.aspx
page1.aspx.cs
This has dec (public partial class _Default : BaseClass.MainPage ) in it.

Then the base class

MainPage.cs
This has the dec ( public class MainPage : System.Web.UI.Page ) in it.

Well it seems that it all compiles and runs ok but I cannot access any of
the aspx objects from the base class MainPage.CS

Hope this helps with the explination?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top