SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 421 | Next

Rob Cameron and Dale Michalk

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

The Advanced Repeater web form takes this a few steps further. Instead of just
binding a SqlDataReader to a Repeater control, the Advanced Repeater web form hooks into the
ItemCreated and ItemDataBound events of our Repeater control to dynamically alter its output.
The Advanced Repeater web form dynamically adds an ASP.NET Label control to each
RepeaterItem row in its ItemCreated handler:
protected void repeaterRdrCust_ItemCreated(object o,
ControlsBook2Lib.Ch07.RepeaterItemEventArgs rie)
{
ControlsBook2Lib.Ch07.RepeaterItem item = rie.Item;
if (item.ItemType == ListItemType.Item)
{
Label lblID = new Label();
lblID.ID = "lblID";
item.Controls.Add(lblID);
item.Controls.Add(new LiteralControl(" "));
}
CHAPTER 7 ?–  SERVER CONTROL DATA B INDING 319
Once the control data binds, it changes the value of the added Label control to the
CustomerID value of the current row in the SqlDataReader:
protected void repeaterRdrCust_ItemDataBound(object o,
ControlsBook2Lib.Ch07.RepeaterItemEventArgs rie)
{
ControlsBook2Lib.Ch07.RepeaterItem item = rie.Item;
DbDataRecord row = (DbDataRecord)item.DataItem;
string ID = (string)row["CustomerID"];
Label lblID = (Label)item.FindControl("lblID");
lblID.Text = ID;
}
The result of the event handling during creation and data binding is the browser output
shown in Figure 7-7.


Pages:
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6