Transcript Grid View

TRAINING SESSIONS
.NET Controls
 Standard








Controls
Label
Textbox
Checkbox
Button, Image Button, Image control
Radio Button
Literal
Hyperlink
Panel
 Validation






Controls
Required Field Validator
Range Validator
Compare Validator
Regular Expression Validator
Custom Validator
Validation Summary
 Datasource Controls





SQL Datasource
XML Datasource
Object Datasource
Access Datasource
Sitemap Datasource
 Data







Bound Controls
Grid View
List View
Details View
Form View
Repeater
Data List
Drop Down List
Grid View
 Displays tabular
data
 Display, edit, and delete data from many different
kinds of data sources, including databases, XML
files, and business objects that expose data.
 Automatically bind to and display data from a data
source control.
 Select, sort, page through, edit, and delete data
from a data source control.
 Specifying custom columns and styles.
 Adding your own code to the functionality of
the control by handling events.
Grid View - Data binding
 DatasourceID

Bind to datasource control
 DataSource

Bind to various objects



Datasets
Data tables
Collections
Grid View - Data binding using
DatasourceID
Grid View - Data binding using
DataSource
Grid View - Data binding using
DataSource
Grid View - Sorting
 Enable
AllowSorting property to true
 Setting PageSize for paging
Grid View - Paging
 Enable
AllowPaging property to true
 Column headers are rendered as links for sorting
the data in ascending or descending order
 When using
explicitly specified fields with a
GridView, such as BoundFields, you need to
specify values for the fields’s SortExpression
properties.
 Otherwise, nothing happens when you click a
header.
Grid View – Editing and Deleting Data
 Enables
you to edit database data
 Without writing single line of code
 Set
AutoGenerateEditButton and
AutoGenerateDeleteButton to true
 Set DataKeyNames property to Primary key of the
database table
 UpdateCommand and DeleteCommand are to be
specified in the SQLDataSource being used
Grid View – Fields
 BoundField—Enables
you to display the value of a
data item as text.
 CheckBoxField—Enables you to display the value
of a data item as a check box.
 CommandField—Enables you to display links for
editing, deleting, and selecting rows.
 ButtonField—Enables you to display the value of a
data item as a button (image button, link button,
or push button).
 HyperLinkField—Enables you to display the value
of a data item as a link.
Grid View – Fields
BoundField—Display the value of data item as text.
 CheckBoxField—Display the value of data item as a check
box.
 CommandField—Enables you to display links for editing,
deleting, and selecting rows.
 ButtonField—Enables you to display the value of a data
item as a button
 HyperLinkField—Enables you to display the value of a data
item as a link.
 ImageField—Enables you to display the value of a data item
as an image.
 TemplateField—Enables you to customize the appearance
of a data item.

Detail View
 Renders HTML
table
 Displays the contents of single database record
Detail View
 Display, edit,
and delete data single record at a
time.
 Specifying custom columns and styles.
 Adding your own code to the functionality of
the control by handling events.
Detail View - Data binding
 DatasourceID

Bind to datasource control
 DataSource

Bind to various objects



Datasets
Data tables
Collections
Detail View - Data binding using
DatasourceID
Detail View - Data binding using
DataSource
Client Side Code
Server Side Code
Form View
 Similar
to Detail View.
 Template Driven
Form View - Data binding using
DatasourceID
Repeater
 Entirely
template driven
 Produces list of individual items
 The control repeats the layout for each item in the
data source.
Repeater- Data binding using
DatasourceID
Repeater- Templates
 ItemTemplate
—Formats each item from the data
source.
 AlternatingItemTemplate—Formats every other
item from the data source.
 SeparatorTemplate—Formats between each item
from the data source.
 HeaderTemplate—Formats before all items from
the data source.
 FooterTemplate—Formats after all items from
the data source.
DataList
 Entirely
template driven
 Renders HTML table
 Supply the control with an ItemTemplate.
 The contents of the ItemTemplate are rendered
for each data item from the data source.
DataList
 The RepeateLayout Property


Table – Data Items are rendered in HTML Table cells
Flow - – Data Items are rendered in HTML Span tags
 Render contents in


Multi- Column table
RepeatColumns – No of columns
RepeatDirection – Direction of repeat
(Horizontal/Vertical)
 Editing
in DataList is different, it requires
programmatic approach
List View
 Super
flexible GridView Control
 Entirely Template Driven
 Used to display, edit, delete and sort database
data
 Displays database records in multiple columns
 Similar to the DataList and Repeater controls
 Unlike those controls, with the ListView control
you can enable users to edit, insert, and delete
data, and to sort and page data, all without code.
 You can group items using Group Template
 Learn
and prepare document for Standard Controls
 Difference between data controls
 Implement a Grid View using


DatasourceID
DataSource
 Implement Edit/Delete and
Sort/Paging functionality in
Grid View
 Explore events of Grid View
 Implement simple functionality of all controls listed in this
ppt