VS.NET Intellisense Support for Exposing DataGridColumnCollection in a UserControl

Discussion in 'ASP .Net Building Controls' started by olliecwl, Apr 12, 2007.

  1. olliecwl

    olliecwl Guest


    I have a UserControl that contains an AJAX.NET UpdatePanel wrapped
    around a DataGrid. I'm exposing the datagrid's column collection as a
    public property of the UserControl. It looks something like this:

    public DataGridColumnCollection Columns
    get { return InnerGrid.Columns; }

    When used on a page, the UserControl looks something like this:

    <my:CopyGrid ID="CopyTheseItems" runat="server">
    <ItemTemplate><b><%# Container.DataItem %></b></ItemTemplate>

    This functions as I'd hoped.

    The problem is in the building of the page. When creating the
    UserControl on a page, I get the option to add a Columns inner
    property tag. However, once inside that tag, I get NO Intellisense
    support for the various DataGridColumn objects. For whatever reason,
    it reverts back to the generic UI editor, giving me support for the
    creation of labels, textboxes, panels, etc.

    So after perusing the boards, I found and tried this:

    public class MyDataGridColumnCollectionEditor : CollectionEditor
    public MyDataGridColumnCollectionEditor(Type type) : base(type) { }

    protected override Type CreateCollectionItemType()
    { return typeof(DataGridColumn); }

    protected override Type[] CreateNewItemTypes()
    Type[] types = new Type[] { typeof(TemplateColumn),
    typeof(BoundColumn), typeof(ButtonColumn),
    typeof(DataGridColumn), typeof(HyperLinkColumn)
    return types;

    protected override object CreateInstance(Type itemType)
    DataGridColumn column =
    itemType.GetConstructor(Type.EmptyTypes).Invoke(null) as
    return column;


    public DataGridColumnCollection Columns
    { ... }

    No luck. I also took a look at (and considered revising) the .XSD
    files backing VS.NET, but that's a hornets' nest I'd rather avoid if I

    So... any thoughts? Like I wrote above, the UserControl works as I'd
    hoped; the problem I'm having is developing with it in an efficient
    and intuitive manner.

    Your thoughts are appreciated.

    olliecwl, Apr 12, 2007
    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.