Wind shadows ASP. NET basics 11 formview

Source: Internet
Author: User
ArticleDirectory
    • Common formview templates

 

In terms of functionality and usage, formview and detailsview are very similar. The formview control allows you to use a single record of the data source. It is also used to update and insert new records, which are usually used in detailed schemes. In these schemes, the selected records of the master control determine the records to be displayed in the formview control.

The difference between the formview and detailsview controls is that the detailsview control uses a table layout. In this layout, each field of the record is displayed as a row, the formview control does not specify the predefined layout for displaying records. It is more flexible than the detailsview control in display. In fact, a template containing controls is created to display fields in the record. The template can contain the format, control, and binding expression used to create a form.

You can create a template to generate a user interface for the formview control and specify different templates for different operations.

Common formview templates
edititemtemplate defines the content of a Data row when the formview control is in editing mode. This template usually contains the input controls and command buttons that you can use to edit existing records
emptytemplate define the template content when no data exists
footertemplate define the bottom content
headertemplate define the content of the header
itemtemplate define the content of a Data row when the formview control is in read-only mode
insertitemtemplate defines the content of a Data row when the formview control is in insert mode.
pagertemplate defines the paging function.

 

As follows:CodeAs shown in

 
<Form ID= "Form1" Runat= "Server">
 
<Div>
 
<ASP: formview ID= "Formview1" Runat= "Server" Performanceid= "Sqlperformance1">
 
<Itemtemplate>
<B>
 
<%# Eval ("ID")%>
 
<%# Eval ("Title")%>
 
</B>
 
<HR />
 
<Small>
<Li><%# Eval ("Publishdate")%></Li>
 
<Li><%# Eval ("Unitprice")%></Li>
 
<Li><%# Eval ("Categoryid")%></Li>
</Small>
 
</Itemtemplate>
 
</ASP: formview>
 
<ASP: sqldatasource ID= "Sqlperformance1" Connectionstring= "<% $ Connectionstrings: con %>" Runat= "Server" Selectcommand= "Select * From books"> </ASP: sqldatasource>
</Div>
 
</Form>

Running result:

Like detailsview, formview also provides many built-in features that allow us to update, delete, insert, and pagination items in the control. When the formview control is bound to a data source control, the formview control can use the function of the data source control and provide automatic update, deletion, insertion, and paging functions.

It is worth noting that formview uses a template, so this control does not provide automatic generation of command buttons to execute update, Delete Insert, and other methods, therefore, we need to manually include these commands in the appropriate template. The formview control recognizes the commandname attribute. The following lists the command buttons that can be identified.

cancel cancel return default mode
Delete delete data
edit edit enters the editing mode
insert insert data
New New enters the insert mode
page if you set page operations, set the commandargument attribute of the button to "Next", "Prev", "first ", "last"
Update Update Data
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.