Pergunta

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.

Foi útil?

Solução

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)
{

}

Outras dicas

You can this :

  <asp:ListView onitemcommand="inner_ItemCommand" ...

protected / public item command method need :

  public void inner_ItemCommand(object sender,  ListViewCommandEventArgs e)
    {
        if (e.CommandArgument == "delete")
        {
            //do delete here
        }
    }
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top