Hi Augustin,
I think that is not as easy as I would hope...the DDL on
UserControlBase will not appear on the subclass. I have read a few
things about this.
Solved my problem another way - created a generic user control with a
drop down list inside it.
It contains genreric properties and methods like those described and
some special methods for filling certain DDLs, e.g. I use the generic
fill method to fill the offices, but to fill the employee ddl I need
more complicated logic...this is done in a second fill method.
OfficeDDL1.Generic_DDL_Load(); // fills the office ddl
EmployeeDDL1.Employee_DDL_Load(officeID) // fills the employee ddl
Thanks for your help.
Bryan
Augustin Prasanna wrote:
Bryan,
see if this will help.
a) create a class 'UserControlBase' that will subclass
System.Web.UI.UserControl.
b) Move common code to 'UserControlBase' class.
c) Inherit 'UserControlBase' class 'Shop', 'Employee' user controls.
Will this work?
Regards,
Augustin
"bryan" wrote:
Hi all,
I am developing a web app in .net 2.0.
I have a few DropDownLists that are used on multiple web forms, these
show shop locations and employees.
Each DDL is placed inside a Usercontrol and the user controls are
placed on the relevant pages.
In order to get at some of the properties of the DDLs from their host
web forms I have written methods and properties like the following -
public ListItem SelectedItem
{
get { return DDL_Employee.SelectedItem; }
}
public IDataReader DataSource // set the data source od the DDL
{
get { return _dataSource; }
set { _dataSource = value; }
}
public void Employee_DDL_Load(ref string MessageText)
{
IDataReader myCategories = null;
CommonHelper.ExecuteCommonReader(ref myEmployee,
"ES_Employee_GetEmployees", ref MessageText);
DDL_Employee.DataTextField = "Employee";
DDL_Employee.DataValueField = "EmployeeID";
DDL_Employee.DataSource = myCategories;
DDL_Employee.DataBind();
DDL_Employee.Items.Insert(0, new ListItem("-- Select
Employee--", "0"));
}
.
.
///plus many other methods and properties
The problem is --- the user control for the shop locations contains
almost identical code as shown for employees. I will soon add other
DDLs for customers, products, etc...
Please advise me on how I can combine all this common code?
Thanks,
Bryan