- Using the DataBound Event Handler[1]
DataSource property and calling its DataBind() method, the following sequence of steps occur:- The data Web control's
DataBindingevent fires. - The data is bound to the data Web control.
- The data Web control's
DataBoundevent fires.
DataBound event we can programmatically determine the data that has been bound to the data Web control and adjust the formatting as needed.These three simple steps are sufficient for web controls like DetailsView and FormView because they display only a single record. For the GridView, which displays all records bound to it (not just the first), step 2 is a bit more involved:
In step 2 the GridView enumerates the data source and, for each record, creates a
GridViewRow instance and binds the current record to it. For each GridViewRow added to the GridView, two events are raised:RowCreatedfires after theGridViewRowhas been createdRowDataBoundfires after the current record has been bound to theGridViewRow.
- The GridView's
DataBindingevent fires. - The data is bound to the GridView.
For each record in the data source
- Create a
GridViewRowobject - Fire the
RowCreatedevent - Bind the record to the
GridViewRow - Fire the
RowDataBoundevent - Add the
GridViewRowto theRowscollection
- Create a
- The GridView's
DataBoundevent fires.
RowDataBound event.- Paging Server-Side Workflow [2]:
- The GridView's (or DetailsView or FormView)
PageIndexChangingevent fires - The ObjectDataSource re-requests all of the data from the BLL; the GridView s
PageIndexandPageSizeproperty values are used to determine what records returned from the BLL need to be displayed in the GridView - The GridView s
PageIndexChangedevent fires
Related articles:
[1] - Custom Formatting Based Upon Data
[2] - Paging and Sorting Report Data
No comments:
Post a Comment