I am creating a custom DataGrid control and am running into a problem. When I add my control to the webform, it says "Error Creating Control".
I know it has something to do with me trying to add default columns, but I don't know why.
When you drop the ASP.NET DataGrid on a webform it renders with 3 columns (0,1 and 2) then abc in all the cells.
That is what I am trying to do, but if I don't try to add default columns it just renders as a gray bar (like a user control).
Any ideas on how I can get it to render like the built in datagrid???

Here's the code
VB Code:
  1. Imports System
  2. Imports System.Web
  3. Imports System.Web.UI
  4. Imports System.Web.UI.WebControls
  5. Imports System.ComponentModel
  6. Imports System.Drawing
  7.  
  8. Public Class JHADataGrid
  9.     Inherits DataGrid
  10.  
  11.     Private JHADataGrid As DataGrid
  12.     Private HeaderStyleProps As HeaderStyleProperties
  13.     Private AlternatingItemStyleProps As AlternatingItemStyleProperties
  14.  
  15.     Public Sub New()
  16.         Dim i As Integer
  17.         Dim dgColumn As DataGridColumn
  18.  
  19.         JHADataGrid = New DataGrid
  20.         HeaderStyleProps = New HeaderStyleProperties
  21.         AlternatingItemStyleProps = New AlternatingItemStyleProperties
  22.  
  23.         JHADataGrid.ID = "JHADataGrid1"
  24.         [color=red]This is the area in question
  25.         For i = 1 To 3
  26.             JHADataGrid.Columns.Add(dgColumn)
  27.         Next
  28.        [/color]
  29.  
  30.     End Sub
  31.  
  32.     <DefaultValue(""), _
  33.     Category("HeaderStyle"), _
  34.     PersistenceMode(PersistenceMode.InnerProperty)> _
  35.     Public Shadows Property [HeaderStyle]() As HeaderStyleProperties
  36.         Get
  37.             Return HeaderStyleProps
  38.         End Get
  39.         Set(ByVal Value As HeaderStyleProperties)
  40.             HeaderStyleProps = Value
  41.         End Set
  42.     End Property
  43.  
  44.     <DefaultValue(""), _
  45.     Category("AlternatingItemStyle"), _
  46.     PersistenceMode(PersistenceMode.InnerProperty)> _
  47.     Public Shadows Property [AlternatingItemStyle]() As AlternatingItemStyleProperties
  48.         Get
  49.             Return AlternatingItemStyleProps
  50.         End Get
  51.         Set(ByVal Value As AlternatingItemStyleProperties)
  52.             AlternatingItemStyleProps = Value
  53.         End Set
  54.     End Property
  55.  
  56.     Protected Overrides Sub render(ByVal writer As HtmlTextWriter)
  57.         EnsureChildControls()
  58.         MyBase.Render(writer)
  59.     End Sub
  60.  
  61.     Protected Overrides Sub CreateControlHierarchy(ByVal useDataSource As Boolean)
  62.  
  63.     End Sub
  64.  
  65.     Protected Overrides Sub PrepareControlHierarchy()
  66.  
  67.     End Sub
  68.  
  69.     'Hide the Font property in the properties window
  70.     <Browsable(False), _
  71.     EditorBrowsable(EditorBrowsableState.Never)> _
  72.     Public Overrides ReadOnly Property Font() As FontInfo
  73.         Get
  74.             Return MyBase.Font
  75.         End Get
  76.     End Property
  77. End Class