简体   繁体   中英

ASP.NET DataGrid ItemDataBound Event

DataGrid has 2 events:

ASP.NET DataGrid:

ItemCreated 
ItemDataBound 

When you bind to a data source ItemCreated gets fired followed by ItemDataBound.

I need to know if anyone can think of any good reason of using ItemCreated .

I can't find anything versus putting the whole code in ItemDataBound event(other than keep the event handler's code smaller).

Please let me know if you think otherwise.

ItemCreated在回发时触发,但ItemDataBound仅在数据绑定期间触发。

ItemCreated is fired before the data bind actually happens. You would normally put code dealing with the appearance and non bound content of the grid in this event.

ItemDataBound is fired after the data bind. You would normally put code dealing with the data here.

ItemCreated基本上在那里可以与UI交互,是的,您也可以对ItemDataBound事件执行完全相同的操作/也可以在其中创建UI更改...我更喜欢DataBound,因为那时数据已经存在,但是我了解ItemCreated的目的

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM