سؤال

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.

هل كانت مفيدة؟

المحلول 3

ItemCreated is basically there for you to interact with UI things, and yes, you can do the exact same thing on the ItemDataBound event as well/create your UI changes there too... i prefer DataBound because then the data is already there, but i understand the purpose of ItemCreated

نصائح أخرى

ItemCreated is fired on the postbacks, but ItemDataBound only during databinding.

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top