F
Frank
Hi all,
I want to derive a class from DataGrid so that I can have
a label on the top.
But when I tried to add the control to my form, I got an
error "Specified cast is not valid" on the line:
MyBase.Render(w) in the Render function.
Thanks a lot.
Frank
Here is my simple code.
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Dim g As New Grid2
Me.Form1.Controls.Add(g)
End Sub
Public Class Grid2
Inherits DataGrid
Dim _label1 As New Label
Protected Overrides Sub OnInit(ByVal e As EventArgs)
Me.Controls.Add(Me._label1)
End Sub
Public ReadOnly Property Label1() As Label
Get
Return Me._label1
End Get
End Property
Protected Overrides Sub Render(ByVal w As
HtmlTextWriter)
MyBase.Render(w)
Me._label1.RenderControl(w)
End Sub
End Class
I want to derive a class from DataGrid so that I can have
a label on the top.
But when I tried to add the control to my form, I got an
error "Specified cast is not valid" on the line:
MyBase.Render(w) in the Render function.
Thanks a lot.
Frank
Here is my simple code.
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Dim g As New Grid2
Me.Form1.Controls.Add(g)
End Sub
Public Class Grid2
Inherits DataGrid
Dim _label1 As New Label
Protected Overrides Sub OnInit(ByVal e As EventArgs)
Me.Controls.Add(Me._label1)
End Sub
Public ReadOnly Property Label1() As Label
Get
Return Me._label1
End Get
End Property
Protected Overrides Sub Render(ByVal w As
HtmlTextWriter)
MyBase.Render(w)
Me._label1.RenderControl(w)
End Sub
End Class