views:

10

answers:

0

I am creating a Composite Control which will consist of a GridView and a Panel. I have declared a property called "columns" for my composite control and am not sure on when to add the columns to the gridview that will be rendered. I have a foreach loop that should go through the "Columns" and add them to the gridview's columns, but for some reason it is always empty. I will greatly appreciate any help with this one seeing that I've wasted a whole day on it. I'll paste my code for the property below. Thanks.

    [
    Category("Behavior"),
    Description("The columns associated to the gridview"),
    EditorBrowsable(EditorBrowsableState.Always),
    PersistenceMode(PersistenceMode.InnerProperty)
    ]
    public DataControlFieldCollection Columns
    {
        get
        {
            return _columns ?? new DataControlFieldCollection();
        }
    }

I have tried this loop in the "OnInit", "OnLoad", and "DataBind" events.

    foreach (DataControlField field in Columns)
        _gridView.Columns.Add(field);