GridView Item Template

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top