In c# I am trying to implement a method which I can use to bind data to any control I pass to it (provided of course the control is derived from a databoundcontrol object)
given the method
public void CTLBindData(ref DataBoundControl ctl){ ... }
I get an error when trying to pass derived control to the function
for example the following code
DropDownList lister = new DropDownList();
CTLBindData(ref lister);
Generates a conversion error
Ok I can accept that, but the following confuses me (probably because I am used to c++ not c#)
CTLBindData(ref (DataBoundControl)lister);
in this case I get the error "A ref or out argument must be an assignable variable"
For clarification A Dropdownlist inherits from a list control which inherits from a DataBoundControl
This makes no sense to me I should be able to pass in any object that has been derived from a databound control. It seems that the explicit typecast is causing the problem.
Any clues as to what I am doing wrong?
DC