|
-
Apr 30th, 2004, 12:39 PM
#1
Thread Starter
Frenzied Member
Custom DataGrid Control
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:
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Imports System.Drawing
Public Class JHADataGrid
Inherits DataGrid
Private JHADataGrid As DataGrid
Private HeaderStyleProps As HeaderStyleProperties
Private AlternatingItemStyleProps As AlternatingItemStyleProperties
Public Sub New()
Dim i As Integer
Dim dgColumn As DataGridColumn
JHADataGrid = New DataGrid
HeaderStyleProps = New HeaderStyleProperties
AlternatingItemStyleProps = New AlternatingItemStyleProperties
JHADataGrid.ID = "JHADataGrid1"
[color=red]This is the area in question
For i = 1 To 3
JHADataGrid.Columns.Add(dgColumn)
Next
[/color]
End Sub
<DefaultValue(""), _
Category("HeaderStyle"), _
PersistenceMode(PersistenceMode.InnerProperty)> _
Public Shadows Property [HeaderStyle]() As HeaderStyleProperties
Get
Return HeaderStyleProps
End Get
Set(ByVal Value As HeaderStyleProperties)
HeaderStyleProps = Value
End Set
End Property
<DefaultValue(""), _
Category("AlternatingItemStyle"), _
PersistenceMode(PersistenceMode.InnerProperty)> _
Public Shadows Property [AlternatingItemStyle]() As AlternatingItemStyleProperties
Get
Return AlternatingItemStyleProps
End Get
Set(ByVal Value As AlternatingItemStyleProperties)
AlternatingItemStyleProps = Value
End Set
End Property
Protected Overrides Sub render(ByVal writer As HtmlTextWriter)
EnsureChildControls()
MyBase.Render(writer)
End Sub
Protected Overrides Sub CreateControlHierarchy(ByVal useDataSource As Boolean)
End Sub
Protected Overrides Sub PrepareControlHierarchy()
End Sub
'Hide the Font property in the properties window
<Browsable(False), _
EditorBrowsable(EditorBrowsableState.Never)> _
Public Overrides ReadOnly Property Font() As FontInfo
Get
Return MyBase.Font
End Get
End Property
End Class
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Apr 30th, 2004, 01:07 PM
#2
Thread Starter
Frenzied Member
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
May 2nd, 2004, 08:23 PM
#3
Frenzied Member
code file? same name bs because the desiner won't @#$%^&* remove code it inserts?
Magiaus
If I helped give me some points.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|