Find jobs | Jobseekers
Employer login
About us Sitemap of www.CareerRide.com Sitemap FAQ related with www.CareerRide.com FAQ Click here to Contact us Contact
       
Submit Resume Free ! | Access Resume Free !
Home Career Services Resume Services Interview questions Articles Books
Content
ASP.NET Part 1
ASP.NET Part 2
ASP.NET Part 3
ASP.NET Part 4
ASP.NET Part 5
ASP.NET Advantages
ASP.NET Issues
ASP.NET Life cycle
ASP.NET Server control
ASP.NET Server vs. HTML
ASP.NET Datalist control
ASP.NET Application & session
ASP.NET Navigation method
ASP.NET Validation control
ASP.NET State Management
ASP.NET Caching
ASP.NET Exception Handling
ASP.NET Master pages
ASP.NET Tutorial
Session state management
Authentication-Authorization
Globalization-Localization
 
ASP.NET | ADO.NET | AJAX
C#.NET | VB.NET | PHP
NET Remoting | NET Interview
  
C | C++ | Java | Oops
Data Structure | OS
   
Database concepts | Oracle
SQL Server | Biztalk | Sharepoint
Notification services
Reporting Services
Service-oriented architecture
Data warehousing | MySQL
  
Project Management 
Linux | Testing | Networking
Software engineering 
  
UML | XML | HTML | SOAP 
CSS | VBScript  | Web Services
   
CV Cover letter | Interview 
HR | Soft skills | GD 
Working from Home 
Tutorial
ASP.NET | VB.NET | C#.NET     
Remoting.NET | Web service
Remoting overview | ADO.NET
UML | Sql server 
More links
Model View Controller 
Understanding Anonymous Types 
Working with the DataList Control 
Windows Presentation Foundation (WPF) 
Books on ASP.NET
ASP.NET 3.5 Application Architecture and Design 
LINQ Unleashed for C# 
ASP.NET Data Presentation Controls Essentials 
Microsoft Expression Blend Unleashed 

ASP.NET Handling the DataList control events


Book Excerpt: Working with the DataList Control

In this chapter, we will cover the ASP.NET DataList control. We will learn about the following:

>Using the DataList control
>Binding images to a DataList control dynamically
>Displaying data using the DataList control
>Selecting, editing and delete data using this control
>Handling the DataList control events


This chapter excerpt from ASP.NET Data Presentation Controls Essentials by Joydip Kanjilal, is printed with permission from Packt Publishing , Copyright 2007.

Handling Events

The Repeater, DataList, and DataGrid controls support event bubbling. What is event bubbling? Event Bubbling refers to the ability of a control to capture the events in a child control and bubble up the event to the container whenever an event occurs. The DataList control supports the following six events: 

ItemCreated
ItemCommand
EditCommand
UpdateCommand
DeleteCommand
CancelCommand

We will now discuss how we can work with the events of the DataList control. In order to handle events when working with a DataList control, include a Button or a LinkButton control in the DataList control. These controls have click events that can be used to bubble up the triggered event to the container control, that is, the DataList.

The following code snippet illustrates how you can attach a handler to an ItemCommand event of a DataList control:

<asp:DataList ID="DataList1" runat="server" onItemCommand = "ItemCommandEventHandler"/>

The corresponding handler that gets called whenever the event is fi red is as follows:

void ItemCommandEventHandler (Object src, DataListCommandEventArgs e ....)
{
      //Some event handling code
}

Simi larly, you can handle the ItemCreated event by specifying the handler in the .aspx file as follows:
<asp:DataList ID="DataList1" runat="server" onItemCreated = "ItemCreatedEventHandler" />

The corresponding handler that is triggered whenever this event occurs is as follows.

void ItemCreatedEventHandler ( Object src, DataListCommandEventArgs e )
{
       //Some event handling code     
}

Similarly, you can use the CancelCommand event by specifying the event handler in your .aspx file as follows:

<asp:DataList ID="DataList1" runat="server" onCancelCommand = .........."CancelCommandEventHandler" />

The corresponding handler that is triggered whenever this event occurs is as follows.

void ItemCreatedEventHandler ( Object src, DataListCommandEventArgs e )
{
        //Some event handling code
}

Similarly, you can use the CancelCommand event by specifying the event handler in your .aspx file as follows:

<asp:DataList ID="DataList1" runat="server" onCancelCommand = .........."CancelCommandEventHandler" />

The corresponding event handler that would get fi red is as follows:

void CancelCommandEventHandler ( Object src, DataListCommandEventArgs e )
{
      //Some event handling code
}

You can handle any of the other events similarly and execute your event handlers appropriately.



 

Today's Hot Jobs
C++  SQL Server
.NET  Java  Oracle
Finance  Marketing
Seekers  Employers
Copyright © 2008 CareerRide.com. All rights reserved.