GridView Item Template

Discussion in 'ASP .Net' started by shapper, Jul 3, 2007.

  1. shapper

    shapper Guest

    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
     
    shapper, Jul 3, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ssoss

    Display Related Item or Add Item

    ssoss, Sep 17, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    502
    ssoss
    Sep 19, 2003
  2. =?Utf-8?B?SmVyb2QgSGF0bGV5?=

    GridView add multiple controls to edit item template

    =?Utf-8?B?SmVyb2QgSGF0bGV5?=, Oct 7, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    1,072
    =?Utf-8?B?SmVyb2QgSGF0bGV5?=
    Oct 8, 2006
  3. Replies:
    2
    Views:
    757
  4. ABHIJIT B
    Replies:
    2
    Views:
    2,337
    ABHIJIT B
    Feb 5, 2008
  5. Desmond Cassidy
    Replies:
    0
    Views:
    575
    Desmond Cassidy
    Apr 7, 2007
Loading...

Share This Page