Packt Publishing ASP.NET Data Presentation Controls Essentials (2007).pdf

(6370 KB) Pobierz
ASP.NET Data Presentation
Controls Essentials
Master the standard ASP.NET server controls for
displaying and managing data
Joydip Kanjilal
BIRMINGHAM - MUMBAI
 
1015573049.019.png 1015573049.020.png 1015573049.021.png 1015573049.001.png 1015573049.002.png 1015573049.003.png 1015573049.004.png
ASP.NET Data Presentation Controls Essentials
Copyright © 2007 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of
the information presented. However, the information contained in this book is sold
without warranty, either express or implied. Neither the author, Packt Publishing,
nor its dealers or distributors will be held liable for any damages caused or alleged to
be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
First published: December 2007
Production Reference: 1141207
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-847193-95-7
www.packtpub.com
Cover Image by Karl Moore ( karl.moore@ukonline.co.uk )
1015573049.005.png
Table of Contents
Preface
1
Chapter 1: Introduction to Data Binding in ASP.NET
5
The ASP.NET Data Binding Model
6
Using the Data Binding Expressions
7
The Employee and the Data Manager Classes
8
New Data Source Controls in ASP.NET 2.0
13
The Object Data Source Control
14
Object Data Source Control Methods
14
The SQL Data Source Control
18
Using the SQL Data Source Control
18
The Access Data Source Control
22
Using the Access Data Source Control
23
The XML Data Source Control
25
Using the XML Data Source Control
25
User Interface and Data Source Paging
27
User Interface and Data Source Sorting
30
Filtering Data Using the Object Data Source Control
33
Summary
34
Chapter 2: Working with List Controls in ASP.NET
35
The ASP.NET List Controls
35
Working with the ListBox Control
36
Appending List Items to the ListBox Control
36
Selecting One or More List Items
38
Removing List Items from the ListBox Control
39
Binding Data to the ListBox Control
40
Handling ListBox Control Events
40
Working with the DropDown List Control
41
Appending List Items to the DropDownList Control
41
Selecting a List Item
43
Removing List Items from the DropDownList Control
43
1015573049.006.png 1015573049.007.png 1015573049.008.png
 
Table of Contents
Binding Data to the DropDownList Control
44
Handling DropDownList Control Events
44
Associating Event Handlers to a dynamically generated DropDownList Control
45
Implementing a Simple Application
46
Working with the CheckBoxList Control
48
Appending List Items to the CheckBoxList Control
48
Selecting One or More List Items
49
Removing List Items from the CheckBoxList Control
50
Binding Data to the CheckBoxList Control
50
Handling CheckBoxList Control Events
51
Implementing a CustomCheckBoxList Control
51
Working with the BulletedList Control
54
Appending List Items to the BulletedList Control
55
Selecting a List Item
56
Removing List Items from the BulletedList Control
57
Binding Data to the BulletedList Control
57
Handling BulletedList Control Events
58
Working with the RadioButtonList Control
58
Appending List Items to the RadioButtonList Control
58
Selecting a List Item
59
Removing List Items from the RadioButtonList Control
60
Binding Data to the RadioButtonList Control
60
Handling RadioButtonList Control Events
60
Summary
61
Chapter 3: Working with the Repeater Control
63
The ASP.NET Repeater Control
63
Using the Repeater Control
64
Displaying Data Using the Repeater Control
67
Displaying Checkboxes in a Repeater Control
70
Implementing Data Paging Using the Repeater Control
73
The BindPagedData() Method
75
Navigating through the Pages
76
Sorting Data Using the Repeater Control
78
Revisiting the DataManager Class
79
Filtering Data Using the Repeater Control
81
Handling Repeater Control Events
87
Summary
89
Chapter 4: Working with the DataList Control
91
The ASP.NET DataList Control
91
Using the DataList Control
92
Displaying Data
93
Handling Events
98
Binding Images Dynamically
100
Selecting Data
102
[ ii ]
 
1015573049.009.png 1015573049.010.png 1015573049.011.png 1015573049.012.png
 
Table of Contents
Editing data
103
Deleting Data
107
Summary
108
Chapter 5: Working with the DataGrid Control in ASP.NET
109
The ASP.NET DataGrid Control
110
Creating a DataGrid Control
110
Implementing a Sample Application Using DataGrid Control
111
Displaying Data
121
Styling the DataGrid Control
123
Appending Data Using the DataGrid Control
127
Editing Data Using the DataGrid Control
132
Deleting Data Using the DataGrid Control
135
Paging Using the DataGrid Control
137
Summary
138
Chapter 6: Displaying Views of Data (Part I)
139
The ASP.NET GridView Control
140
Comparing DataGrid and GridView Controls
144
Displaying DropDownList in a GridView Control
144
Displaying CheckBox in a GridView Control
146
Change the Row Color of GridView Control Using JavaScript
148
Displaying Tool Tip in a GridView Control
151
Paging Using the GridView Control
151
Implementing a Hierarchical GridView
153
Sorting Data Using the GridView Control
162
Inserting, Updating and Deleting Data Using the GridView Control
163
Exporting the GridView Data
169
Formatting the GridView Control
172
Summary
182
Chapter 7: Displaying Views of Data (Part II)
183
Working with the ASP.NET DetailsView Control
183
Using the DetailsView Control
184
Working with the ASP.NET FormView Control
196
Formatting Data Using the FormView Control
200
Working with the ASP.NET TreeView Control
204
Implementing a Directory Structure as a TreeView
210
Summary
214
Chapter 8: Working with LINQ
215
Introducing LINQ
215
Why LINQ?
216
Understanding the LINQ Architecture
216
[ iii ]
 
1015573049.013.png 1015573049.014.png 1015573049.015.png 1015573049.016.png 1015573049.017.png 1015573049.018.png
 
Zgłoś jeśli naruszono regulamin