asp.netlistviewnesteditemdatabound

itemdatabound event of a nested listview


I have a nested listview which I databind on the parent 'ItemDataBound' event, but how do i access/register the nested listview's itemdatabound event?

Thanks!

Edits

My parent listview itemdatabound now looks like so,

Protected Sub lvwManagePolicy_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles lvwManagePolicy.ItemDataBound

    If e.Item.ItemType = ListViewItemType.DataItem Then
        Dim rv As DataRowView = CType(e.Item.DataItem, DataRowView)

        Me.dsAccoutnTransactionHistory = Wrap.getWrapAccountTransactionHistory(rv!PLATFORM_ID, False)
        Dim lvwTransactionHistory As ListView = DirectCast(e.Item.FindControl("lvwTransactionHistory"), ListView)
        lvwTransactionHistory.ItemDataBound += New EventHandler(Of ListViewItemEventArgs)(lvwTransactionHistory_ItemDataBound)
        lvwTransactionHistory.DataSource = dsAccoutnTransactionHistory
        lvwTransactionHistory.DataBind()
    End If

End Sub

but i get an error

BC32022: 'Public Event ItemDataBound(sender As Object, e As System.Web.UI.WebControls.ListViewItemEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.


Solution

  • Before assigning the data to nested control in your parent control you can register the event like below under your parent ItemBoundData

    ListView f = new ListView();
    f.ItemDataBound += new EventHandler<ListViewItemEventArgs>(f_ItemDataBound);
    
    protected void f_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
    
    }