Prev | Current Page 437 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"

If the data object is not of type DbDataRecord, it simply
writes out the string value for the object using ToString(), which is why System.Data.DataRowView
is rendered for each row instead of the data from the SqlDataSource. This issue provided us an
excuse to improve the implementation resulting in the EnhancedSpreadSheet control. First, let??™s
take a look at how the CompositeDataBoundControl works.
CompositeDataBoundControl Mechanics
In general, composite control rendering is centered around the CreateChildControls method
that is inherited from the base Control class. The Render method is not overridden in a composite
server control, because the child controls perform their own rendering. By simply creating the
child controls, a composite server control achieves rendering its contents.
When inheriting from CompositeDataBoundControl, it is required to override this method:
CreateChildControls(IEnumerable dataSource,Boolean dataBinding)
When initially loading the page, a dataSource is passed in based on how the control is
configured for data binding and dataBinding is set to true. The rows are built out with data
from the configured data source and rendered to the browser. Upon postback, the value for the
dataSource parameter is an array of null objects that has a count that matches the number of
rows added to the HTML Table??™s Rows collection.


Pages:
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449