RowCreated is fired when the html-controls for a row are created. For example the controls you specify in templates, such as a textbox or a dropdownlist. Databinding has not yet taken place.
After RowDataBound the databound-controls are filled with the actual values. For example a bound SelectedValue property of a DropDownList is set. In this eventhandler you could change these values if needed.
Above that you could for example change properties of non-databound controls but this can also be done in the RowCreated eventhandler.
Most of the time I use the DataBound event. The only moment I use the Created event is when I need to populate a DropDownList with Items. Otherwise databinding would fail.
Greetings,
Sjonnie
Greetings,
Sjonnie
Marked as answer by TATWORTH on Jul 17, 2010 11:05 AM
BogN
Member
130 Points
36 Posts
RowDataBound VS RowCreated
Jun 03, 2006 10:02 AM|LINK
What is the difference between thoes two events?
I am using only the RowCreated, but can u give me an example when to use each event?
thanks BogN,
Sjonnie2nd
Participant
1125 Points
221 Posts
Re: RowDataBound VS RowCreated
Jun 03, 2006 04:13 PM|LINK
BogN,
RowCreated is fired when the html-controls for a row are created. For example the controls you specify in templates, such as a textbox or a dropdownlist. Databinding has not yet taken place.
After RowDataBound the databound-controls are filled with the actual values. For example a bound SelectedValue property of a DropDownList is set. In this eventhandler you could change these values if needed.
Above that you could for example change properties of non-databound controls but this can also be done in the RowCreated eventhandler.
Most of the time I use the DataBound event. The only moment I use the Created event is when I need to populate a DropDownList with Items. Otherwise databinding would fail.
Greetings,
Sjonnie
Sjonnie
summer.hu
Member
29 Points
5 Posts
Re: RowDataBound VS RowCreated
Oct 04, 2007 01:54 AM|LINK
Hi BogN,
RowCreated is focused on parsing Gridview row's definition and creating the Gridview row's control structure,
RowDataBound is focused on bind data to the row's controls created in the RowCreated.
Also RowCreated is invoked automatically in both init and postback case, but RowDataBound is only invoke when the DataBind is called.
Regards
Summer
Mohammed Ask...
Contributor
2370 Points
535 Posts
Re: RowDataBound VS RowCreated
Jan 19, 2010 07:13 AM|LINK
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.onrowdatabound.aspx
http://askarnet.wordpress.com