Pass webcontrol into class

P

Paul

Hi all,

I have a set of dynamically built objects (built based on saved
preferences) which are loaded into a placeholder on page load. Each
object controls and populates a webcontrol. I'm currently looking at
the best way to save the data in these controls on a save button being
clicked. Because a control can be any kind of webcontrol, I was
considdering passing the control itself (or even the placeholder) into
it's object class and then being able to manipulate it there and save
the data. An alternative is to inherit each object class from page and
pull the data out that way - but that way seems to add a lot more size
to the obects. eg:
//interface is used to call load, save, update etc on a list<T> of
different objects

public class someName : iSomeObject
{
private int objectRef;
private PlaceHolder placeholder;

someObject(int _id, ref PlaceHolder _PlaceHolder)
{
objectRef = _id;
placeholder = _PlaceHolder;
loadObj();
}

void loadObj()
{
//use datalayer to accessdb on objRef and pull out data
//create new webcontrol of correct type + populate with db
data
//place webcontrol into placeholder
}

void saveObject()
{
//use placeholder and get object
//pullout webcontrol data
//pass data to datalayer to be saved in db

}
}

Is this a feasible way of doing this?
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top