Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning a web control from a function?
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00713893
Message ID:
00713947
Views:
17
>I have a class which specifically deals with this SQL table.
>
>My form instantiates the class. My class opens a connection and grabs the data from SQL. Now I want to build and return a populated dropdownlist control to the page. It would seem to me I need to pass a reference to the page to my class so I can add the control to it.

Ok, lets call this class that deals with the data a component. You COULD pass a reference to the Page object to your component and just add to it inside your component. This would be a poor design because the data component would be forever bound to some ui page object (or a subclass of it).

A better design would be for the data component to return the data to the UI (as a DataSet, XML, or some type of Collection), and the UI would decide what to do with it. A method on the Presentation tier could iterate through the data and add controls to the Page object if its a Webform or do something similar with a Winform control if you are working with a Windows form. This way you can reuse the data component in any type of project.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform