Using DetailsView and FormView Controls in ASP.NET: A Comparative Study, Slides of Computer Programming

An overview of the detailsview and formview controls in asp.net, explaining their similarities and differences in displaying and editing single records. It covers their characteristics, usage, and configuration with examples.

Typology: Slides

2012/2013

Uploaded on 09/27/2013

vikrant
vikrant 🇮🇳

4.4

(9)

119 documents

1 / 19

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Using the DetailsView
and FormView Controls
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Using DetailsView and FormView Controls in ASP.NET: A Comparative Study and more Slides Computer Programming in PDF only on Docsity!

Using the DetailsView

and FormView Controls

DetailsView (Introduction)

 Use the DetailsView control to  Display a single record at a time  Insert, edit, and delete records

DetailsView

Characteristics (2)

 Basically, the element replaces the element  Styles work similarly  AlternatingRowStyle, CommandRowStyle, EditRowStyle, InsertRowStyle, etc…

DetailsView (Example)

 Just by binding the DetailsView to a DataSource, you get basic selection and editing capabilities See DetailsViewExample

DetailsView (Configuring 2)

DetailsView

(Fields Introduction)

 If the AutoGenerateFields property is true, the fields will be created automatically  If not, you need to create each field manually

DetailsView (Fields 1)

 Take a look at the Field Editor (fields have different types)  The following are used to create visible controls to display bound data (Set the DataField property  BoundField  CheckBoxField  HyperLinkField  ImageField  ButtonField

DetailsView (Fields 2)

 Use the CommandField to display automatically wired buttons  ShowDeleteButton  ShowInsertButton  ShowEditButton

Example: <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />

DetailsView

(Updating Records)

 Like the GridView  The DataKeyNames property must define a record key  The data source must be set up for updates  Create CommandFields for the Insert, Update, and Delete buttons  See DetailsViewExample2.aspx

DetailsView

(Templated Fields)

 You have two choices for field layout  Use what the DetailsView provides  Create a Template field and define the following three templates 

The FormView Control

(Templates 1)

 ItemTemplate appears while a record is NOT being edited or deleted  InsertItemTemplate appears while a record is being inserted  EditItemTemplate appears while a record is being header  EmptyDataTemplate appears when there are no records

The FormView Control

(Templates 2)

 HeaderTemplate is the header row at the top  It can contain any html or ASP controls.  FooterTemplate is the footer row at the bottom  The same is true here

Template Contents

 For each template, you define the bound controls that will display the data, along with the formatting