Abe Miessler
Abe Miessler

Reputation: 85056

Where can I find the order of ListView events?

I was wondering specifically about whether ItemCreated or ItemBound happens first but I can't seem to find any information on the order that ListView events fire. Can anyone point me to a resource for this information?

Note: this is for the System.Web.UI.WebControls.ListView

Upvotes: 1

Views: 1365

Answers (1)

Claudio Redi
Claudio Redi

Reputation: 68410

You can test it handling both events for a ListView and setting breakpoints. I tell you the end of the story: ItemCreated is executed first.

While ItemCreated happens on every request to the page containing the ListView, ItemDataBound only get fired if your control is bound to a data source.

It may happen that you bound your control on the first request and you don't do it on postback, in this case the ViewState information is used and the event ItemDataBound is not fired.

From RadGrid for ASP.NET AJAX (not the same control but the idea applies)

ItemCreated should be hooked when you need to modify the controls inside a grid cell. ItemDataBound should be wired in order to change the data displayed inside a grid cell and its controls.

Upvotes: 1

Related Questions