Home All Groups Group Topic Archive Search About

ASP.NET GridView UserControl

Author
6 Jan 2006 3:12 PM
JAWS
I want to make an ASP.NET user control with only a gridview on it.

My usercontrol must behave the same as a normal gridview, with some
extra
properties and methods (for security purposes, such as: invisible,
readonly etc..)

I can not inherit the gridview from webcontrols.gridview because this
causes an error.
(Compile error: "property 'SupportAutoEvents' cannot be declared
'Overrides' because it does not override a property in a base class"),
so I made my own properties and methods.

I can bind data to myGridView and this works fine, but when I want to
customize the columns (at run-time). Such as headertext, first column
invisible etc...
This is the property for the columns:

Property Columns(ByVal index As Integer) As
System.Web.UI.WebControls.DataControlField
        Get
            Return GridView1.Columns(index)
        End Get
        Set(ByVal value As System.Web.UI.WebControls.DataControlField)
            GridView1.Columns(index).Visible = value.Visible
        End Set
End Property

This doesn't work, can anyone tell me why?

How can I setup usercontrols with only 1 control and inherit all
properties, methods and events from this 'base' control, so I only have
to add my own properties?
This because I also have to make usercontrols of textbox, buttons
etc...

Thanx in advance...

Author
6 Jan 2006 3:17 PM
Remy
Below is an example of someone that developed his own datagrid based on
the .net datagrid.
That should give you some hints on how to do this.

http://msdn.microsoft.com/msdnmag/issues/03/10/CuttingEdge/

Remy Blaettler

Bookmark and Share