S
shapper
Hello,
I am trying to create a GridView at runtime but my GridView has 4 rows
but only the last one is filled. Why?
Here is my code:
' tfPost
Private Class tfPost
Implements ITemplate
Protected WithEvents lPost As New Label
Private Type As ListItemType
' lPost_DataBinding
Private Sub lPost_DataBinding(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lPost.DataBinding
' Create lPost
Dim lPost As Label = CType(sender, Label)
' Create container
Dim gvrContainer As GridViewRow = CType(lPost.NamingContainer,
GridViewRow)
' Bind lPost
lPost.Text = DataBinder.Eval(gvrContainer.DataItem,
"PostTitle") & "<br />" & _
DataBinder.Eval(gvrContainer.DataItem,
"PostBody")
End Sub ' lPost_DataBinding
' New
Public Sub New(ByVal type As ListItemType)
' Define template type
Me.Type = type
End Sub ' New
' InstantiateIn
Public Sub InstantiateIn(ByVal container As Control) Implements
ITemplate.InstantiateIn
' Select template type
Select Case Me.Type
Case ListItemType.Header ' Header
template
Case ListItemType.Item ' Item template
container.Controls.Add(lPost)
Case ListItemType.Footer ' Footer template
End Select
End Sub ' InstantiateIn
End Class ' tfPost
End Class
Thanks,
Miguel
I am trying to create a GridView at runtime but my GridView has 4 rows
but only the last one is filled. Why?
Here is my code:
' tfPost
Private Class tfPost
Implements ITemplate
Protected WithEvents lPost As New Label
Private Type As ListItemType
' lPost_DataBinding
Private Sub lPost_DataBinding(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lPost.DataBinding
' Create lPost
Dim lPost As Label = CType(sender, Label)
' Create container
Dim gvrContainer As GridViewRow = CType(lPost.NamingContainer,
GridViewRow)
' Bind lPost
lPost.Text = DataBinder.Eval(gvrContainer.DataItem,
"PostTitle") & "<br />" & _
DataBinder.Eval(gvrContainer.DataItem,
"PostBody")
End Sub ' lPost_DataBinding
' New
Public Sub New(ByVal type As ListItemType)
' Define template type
Me.Type = type
End Sub ' New
' InstantiateIn
Public Sub InstantiateIn(ByVal container As Control) Implements
ITemplate.InstantiateIn
' Select template type
Select Case Me.Type
Case ListItemType.Header ' Header
template
Case ListItemType.Item ' Item template
container.Controls.Add(lPost)
Case ListItemType.Footer ' Footer template
End Select
End Sub ' InstantiateIn
End Class ' tfPost
End Class
Thanks,
Miguel