Prev | Current Page 390 | Next

Rob Cameron and Dale Michalk

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

The return value of true indicates to
ASP.NET that the event was handled. Later on, we show the code in Repeater that handles the
bubbled event and raises its own Command event.
We create a custom EventArgs class to make working with the Repeater control easier, as
shown in Listing 7-1. Instead of having to search through all the controls that are in the Repeater??™s
Control collection, we can narrow it down to just the RepeaterItem control of interest.
Listing 7-1. The RepeaterCommand Event Class File
using System;
using System.Web.UI.WebControls;
namespace ControlsBook2Lib.Ch07
{
public delegate void RepeaterCommandEventHandler(object o,
RepeaterCommandEventArgs rce);
CHAPTER 7 ?–  SERVER CONTROL DATA B INDING 287
public class RepeaterCommandEventArgs : CommandEventArgs
{
public RepeaterCommandEventArgs(RepeaterItem item, object commandSource,
CommandEventArgs originalArgs) : base(originalArgs)
{
this.item = item;
this.commandSource = commandSource;
}
private RepeaterItem item;
public RepeaterItem Item
{
get
{
return item;
}
}
private object commandSource;
public object CommandSource
{
get
{
return commandSource;
}
}
}
}
The source of the event is available in the RepeaterCommandEventArgs class via the
CommandSource property.


Pages:
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402