我应该执行哪个生命周期事件才能在 Gridview 完全加载后执行代码?

Which life-cycle event should I execute my code in order for it to be after a Gridview is completely loaded?

我有一个简短的问题。我有一个 gridview,它会因相对较长的加载时间而产生较大的结果。我想等到 gridview 完全填充和加载,直到我执行某个代码。我会在 Page_Load 下使用它吗?我在看 these life-cycles,看起来它也可能属于其他人,例如 LoadComplete。

如果代码与完成后处理 GridView 相关,那么最明显的事件就是 OnDataBound 事件。

活动说明

This method notifies a server control that any data binding logic associated with the control has completed.

如果您使用 DataBind 显式填充 GridView,请在调用 DataBind 之后执行此操作。

如果在 aspx 页面中 "automatically" 使用 datasourceid= 填充 GridView,那么您可以在页面加载事件中执行任何操作。