Groups | Blog | Home
all groups > asp.net building controls > february 2005 >

asp.net building controls : Adding Datasource Property


Steven W
2/15/2005 4:23:05 AM
I need help with how to add a DataSource property to a composite control and
then how to assign that property to the datasource of a datagrid.

Wilco Bauwer
2/16/2005 11:36:08 AM
You could use aggregration, e.g.: create a composite control which
contains a datagrid, and add a DataSource property which looks like:

public object DataSource
{
get
{
this.myDataGrid.EnsureChildControls();
return this.myDataGrid.DataSource;
}
set
{
this.myDataGrid.EnsureChildControls();
this.myDataGrid.DataSource = value;
}
}

You should create the datagrid in the CreateChildControls method.
Steven W
2/16/2005 12:57:04 PM
Thanks. That's a better solution than the path I was heading down.

[quoted text, click to view]
AddThis Social Bookmark Button