DataView control: other interesting events

Published Tue, Oct 27 2009 10:12

In these last posts, we’ve already met several of the events generated by the DataView control. I thought it would be a good idea to write a small post which documents many of the events we’ve seen in the past:

command: fired when a user clicks over an element which has been “marked” with the sys:command system attribute;

  • rendering: this event is generated when the DataView control is about to start instantiating its template to get the rendered HTML. Any function which handles this event receives two parameters: the first, references the DataView control which generated the event; the second is an instance of the Sys.Data.DataEventArgs type.;
  • rendered: marks the end of the HTML rendering process. Functions configured as handlers receive two parameters: the first, references the DataView which generated the event; the second, is an instance of the Sys.DataDataEventArgs type;
  • itemRendering: event that is generated before each item’s template instantiation. We can do several interesting things here, like changing the default template or influencing the data that is going to be used during the template instantiation;
  • itemRendered: event which signals the end of the instantiation of a template. We’ve seen how we can use this event to customize the generated HTML for an item.

The Sys.Data.DataEventArgs object used by the rendering and rendered events introduces some interesting properties:

  • data: references the items that will be used for instantiating the templates;
  • itemPlaceholder: used for identifying the place holder where the template’s generated HTML will be put;
  • itemTemplate: reference to the template used for instantiating all the elements.

During the rendering event, you can set all of these properties  and influence the HTML generated by the DataView control.

Besides these events, there are still others, but we’ll leave them for the next posts because they’re related with the integration of the DataView control with data contexts. Stay tuned for more on MS AJAX.

Filed under: ,

Comments

# william apken said on Tuesday, October 27, 2009 5:58 AM

The Sys.Data.DataEventArgs object used by the rendering and rendered events introduces some interesting properties:

data: references the items that will be used for instantiating the templates;

itemPlaceholder: used for identifying the place holder where the template’s generated HTML will be put;

itemTemplate: reference to the template used for instantiating all the elements.

During the rendering event, you can set all of these properties  and influence the HTML generated by the DataView control.

Does that last statement only apply when you are using local data  as opposed to using data returned by the fetchOperator ?  In my case you would not use the data:property but rely on the fetchOperator.

# luisabreu said on Tuesday, October 27, 2009 6:03 AM

i'm still investigating the data context and derived classes. i'll be returning to that topic in future posts :)

Leave a Comment

(required) 
(required) 
(optional)
(required) 
If you can't read this number refresh your screen
Enter the numbers above:  

Search

This Blog

Tags

Community

Archives

Syndication

Email Notifications

News




  • View Luis Abreu's profile on LinkedIn


    Follow me at Twitter

    My books

    Silverlight 4.0: Curso Completo

    ASP.NET 4.0: Curso Completo

    Portuguese LINQ book cover

    Portuguese ASP.NET 3.5 book cover

    Portuguese ASP.NET AJAX book cover

    Portuguese ASP.NET AJAX book cover