Instance from property

I

Islam Elkhayat

I hve Dataclasses one for each dbtable & i have user control with MoveNext()
& MovePrev() methods
i want the toolbar to use the current class so i created an Interface
(IDbClasses) with the 2 methods and i use it in the user control,
i also added a poperty of type IDbClasses to pass instance of the current
class like this:

UserControl....

IDataClasses dclass;
<<<<<<<dclass = CurrentObj>>>>>>>>>>>>>;
private IDataClasses currobj;
public IDataClasses CurrentObj
{
get{return currobj; }
set{currobj = value; }
}

in the main form>>
IDataClasses dclass;
UserControl myctrl;
dclass = new Employees();

in the page load...
myctrl = new UserControl();
myctrl.CurrentObj = dclass;


when i click the buttons in the user contrl i get an "object not set an
instance" Exception from the line:
dclass = CurrentObj in the user control how could i fix the error??
 
K

Kevin Spencer

I'm sorry, Islam, I'm not following you at all. Maybe it's just too early in
the morning, but could you clarify?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
I

Islam Elkhayat

I have user control to navigate throw datatble rows and display result in
textboxes... i want to use the same user control and minimize codeing by
call methods like MoveNext(), MovePrev() which is memeber of all classes
[Employees, Categories, orders... I have 100 table].. so i have to
instantiate the the right class in the user control so i can use this
instance to cll methods..
I implemented interface as i said b4 for all classes so i can creat instace
from the type of this interface and i sent the code b4 but i get
"Object reference not set to an instance of an object." Exception..
help plz
 
W

William F. Robertson, Jr.

How are you persisting the CurrentObj across postbacks? Or are you setting
the CurrentObj property on each page load?

I am assuming your CurrentObj is a property of your UserControl.

bill
 

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