CompositeControl with GridView and Columns property

Discussion in 'ASP .Net Web Controls' started by danieljroot, Aug 21, 2006.

  1. danieljroot

    danieljroot Guest

    I'm writing a CompositeControl that includes a child GridView. I want
    to expose the GridView's Columns property at design time and allow the
    developer to customize the columns, but don't want them to set the
    DataSourceID, etc. So, I did this on my control:

    <PersistenceMode(PersistenceMode.InnerProperty), _

    Editor(GetType(System.Web.UI.Design.WebControls.DataControlFieldTypeEditor),
    GetType(UITypeEditor)), _
    MergableProperty(False), _
    DefaultValue(CStr(Nothing)), _

    DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
    _
    Public ReadOnly Property Columns() As
    DataControlFieldCollection
    Get
    Me.EnsureChildControls()
    Return memberGridView.Columns
    End Get
    End Property

    However, the DataControlFieldTypeEditor does not appear when the [...]
    button is clicked in the property grid. No UI or error occurs at all.
    Using Reflector, I suspect that this is because the control is not a
    DataBoundControl:

    Public Overrides Function EditValue(ByVal context As
    ITypeDescriptorContext, ByVal provider As IServiceProvider, ByVal value
    As Object) As Object
    Dim control1 As DataBoundControl =
    TryCast(context.Instance,DataBoundControl)
    If (control1 Is Nothing) Then
    Return Nothing
    End If
    ....

    But I'm stuck there. So, my question is: How can I expose a Columns
    property and get the design-time behavior identical to the GridView?
     
    danieljroot, Aug 21, 2006
    #1
    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.