GRID VIEW CONTROL PG 468 477 DETAIL VIEW

  • Slides: 33
Download presentation
GRID VIEW CONTROL (PG 468 -477) DETAIL VIEW & FORM VIEW CONTROLS (PG 481

GRID VIEW CONTROL (PG 468 -477) DETAIL VIEW & FORM VIEW CONTROLS (PG 481 -491) Group 1 CSCI 5633 01 Presentation ID 31

Outline § The Grid View Control Category Maintenance application Default. aspx file § The

Outline § The Grid View Control Category Maintenance application Default. aspx file § The code-behind file § How to work with template fields § The Template version Category Maintenance application Default. aspx file § Details. View Control introduction § Details. View Control in depth § How to create a Master/Detail Page

Default. aspx file of Grid View Control

Default. aspx file of Grid View Control

Default. aspx file of Grid View Control (cont)

Default. aspx file of Grid View Control (cont)

The code-behind file § Must write code to insert data into Grid. View control

The code-behind file § Must write code to insert data into Grid. View control to catch and handle any database or concurrency error that might occur § 3 Method in the file § btn. Add_click: § set the values of the three insert parameters to the values entered by the user § call the Insert Method of the data source control § Grid. View 1_row. Updated: § § § Called after a row has been update Check the exception property of the e argument. If the Exception. Handled property is set to True, the exception will be suppress. The Keep. In. Edit. Mode Property is set to True to leave the Grid. View control in edit mode If no exception happen, the e arguments Affected. Rows property is checked If it is zero, there is concurrency error and display error message

btn. Add_Click method • set the values of the three insert parameters to the

btn. Add_Click method • set the values of the three insert parameters to the values entered by the user • call the Insert Method of the data source control

Grid. View 1_row. Updated method • Called after a row has been update •

Grid. View 1_row. Updated method • Called after a row has been update • Check the exception property of the e argument. • If the Exception. Handled property is set to True, the exception will be suppress. • The Keep. In. Edit. Mode Property is set to True to leave the Grid. View control in edit mode • If no exception happen, the e arguments Affected. Rows property is checked • If it is zero, there is concurrency error and display error message

Grid. View 1_Row. Deleted method • Called after a row has been deleted •

Grid. View 1_Row. Deleted method • Called after a row has been deleted • Check if the exception been thrown • Check for concurrency error • No set Keep. In. Edit. Mode property to True becayse the control isn’t in edit mode when the Delete button is clicked

What are template fields? § What is a template field? § A template field

What are template fields? § What is a template field? § A template field is simply a field that provides one or more templates that are used to render the column § What is included in these templates? § You can include anything you want in these templates, including labels or text boxes, data binding expressions, and validation controls.

How to create template fields § The easiest way to create template fields is

How to create template fields § The easiest way to create template fields is to first create a regular bound field and then convert it to a template field § This changes the Bound. Field element to a Template. Field element and, more importantly, generates Item. Template and Edit. Item. Template elements that include labels and text boxes with appropriate binding expressions. § Once the bound field is converted to a template you can edit it add any additional element including validation controls

How to create template fields (cont)

How to create template fields (cont)

Grid. View Template Elements

Grid. View Template Elements

A template field that includes a validation control

A template field that includes a validation control

The product maintenance application

The product maintenance application

The Product maintenance Application

The Product maintenance Application

The Default. aspx file

The Default. aspx file

How to use Detailsview control • Designed to display the data for single item

How to use Detailsview control • Designed to display the data for single item of a data source • Work with drop down list

A Details. View Control that displays data for a selected product • Displays data

A Details. View Control that displays data for a selected product • Displays data for a single item of a data source. • Used with a drop-down list or Grid. View control. • Details. View Control with a drop-down list.

The aspx code for Details. View control • <asp: Details. View …> <Fields> Bound.

The aspx code for Details. View control • <asp: Details. View …> <Fields> Bound. Field /> <asp: </Fields> </asp: Details. View> • Data. Source. ID attribute specifies data source. • Bound. Field defines individual fields to be displayed.

Three modes of Details. View control

Three modes of Details. View control

Details. View control attributes

Details. View control attributes

Details. View child elements <asp: Details. View> <Fields> <asp: Bound. Field> <Header. Style Width=“

Details. View child elements <asp: Details. View> <Fields> <asp: Bound. Field> <Header. Style Width=“ 125 px”/> <Item. Style Width=“ 325 px”/> </asp: Bound. Field> </Fields> </asp: Details. View>

Fields Child elements

Fields Child elements

Details. View control Paging • Move from one item to the next by using

Details. View control Paging • Move from one item to the next by using paging controls. • Data from only one row is displayed at a time. • A row of paging control is displayed at the bottom of the Details. View control.

What is Detail Page? § There are two ways to show information from the

What is Detail Page? § There are two ways to show information from the Data source: 1. Grid. View Data control 2. Drop-down list control

1. Grid. View Control

1. Grid. View Control

2. Dropdown list control

2. Dropdown list control

How to update the data in a Detail. View Control? § Command Buttons

How to update the data in a Detail. View Control? § Command Buttons

§ Attributes to generate commands buttons

§ Attributes to generate commands buttons

Command Buttons

Command Buttons