Adding Datasource Property

Discussion in 'ASP .Net Building Controls' started by Steven W, Feb 15, 2005.

  1. Steven W

    Steven W Guest

    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.

    Thanks
     
    Steven W, Feb 15, 2005
    #1
    1. Advertisements

  2. Steven W

    Wilco Bauwer Guest

    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.
     
    Wilco Bauwer, Feb 16, 2005
    #2
    1. Advertisements

  3. Steven W

    Steven W Guest

    Thanks. That's a better solution than the path I was heading down.
     
    Steven W, Feb 16, 2005
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.