ASP. NET first knowledge 7

Source: Internet
Author: User
1. gridview Control
Supported Functions
Bind to a data source, such as sqldatasource, objectdatasource, or linqdatasource Control
Built-in sorting Function
Built-in Record Update and deletion Functions
Built-in data paging Function
Built-in row Selection Function
Allows you to access the gridview object model programmatically, dynamically set attributes, and process events.
You can specify multiple key fields.
Provides multiple data fields for hyperlink Columns
You can customize the appearance through themes and styles.
2. Column Type
Boundfield: displays the value of a field in the data source. Default column type of the gridview Control
Buttonfield: displays a command button for each item of the gridfield control. In this way, you can create a series of Custom button controls, such as the add or remove buttons.
Checkboxfield: displays a check box for each item of the gridview control. The field type of this column is usually used to display fields with Boolean values.
Commandfield: displays the predefined command buttons used to select, edit, or delete an operation.
Hyperlinkfield: displays the value of a field in the data source as a hyperlink. This field type can bind another field to the URL of the hyperlink
Imagefield: displays an image for each item in the gridview control.
Templatefield: displays user-defined content for each item in the gridview Control Based on the specified template. This field type allows developers to create custom column fields.
3. attributes of the boundfield
Datafield: Specifies the name of the field to be bound to the column. If it is a data table, it is a data table field. If it is an object, it is the attribute of the object.
Dataformatstring: used to format the formatted string displayed in datafield. For example, to specify four decimal places for unitprice, you can specify {0: F4} For this column}
Applyformatineditmode: whether to apply the format to the editing mode. The default value is false.
Headertext, footertext, and headerimageurl: The first two attributes are used to set the text displayed in the column header and the end of the column. The headertext attribute is usually used to display the column name. Some statistics can be displayed at the end of a column.
Readonly: whether the column is read-only. By default, the primary key field will be read-only and the read-only field will not enter the insert and edit mode.
Insertvisible: Indicates whether a column can enter the editing mode. This attribute is very useful when it is run and is programmed to control which columns can be inserted.
Visible: whether the column is visible. If set to false, no HTML output is generated.
Sortexpression: Specifies an expression for sorting.
Htmlencode: The default value is true, indicating whether to encode the displayed text in HTML.
Nulldisplaytext: the text to be displayed when the value is null
Convertemptystringtonull: if it is set to true, all null characters are converted to null values when editing is submitted.
Controlstyle, headerstyle, footerstyle, and itemstyle: used to set the column rendering Style
4. gridview control event
Widget rendering event
Databinding: triggered immediately when the gridview control is bound to the data source
Databound: triggered when the gridview control has been bound to the data source
Rowcreated: this event is triggered when rows in the gridview are created.
Rowdatabound: triggered when each row in the gridview is bound to data
Edit record events
Rowcommand: triggered when a button in the gridview control is clicked.
Rowupdating: triggered before the gridview update record
Rowupdated: triggered after the gridview update record
Rowdeleting: triggered before the gridview deletes a record.
Rowdeleted: triggered when a record is deleted in the gridview.
Rowcancelingedit: triggered when the update record is canceled.
Select and sort paging events
Pageindexchanging: triggered before the current page is changed
Pageindexchanged: triggered when the current page is changed
Sorting: triggered before sorting
Sorted: triggered after sorting
Selectedindexchanging: triggered before the row is selected
Selectedindexchanged: triggered after the row is selected
5,

View code

 1   <  ASP: listview ID  =  " Listview2  "  Runat  =  "  Server  "  Performanceid  =  "  Sqldatasource1  "  >  
2 < Layouttemplate >
3 < Fieldset runat = " Server " >
4 < Legend runat = " Server " > Product list </ Legend >
5 < ASP: placeholder runat = " Server " ID = " Itemplaceholder " > </ ASP: placeholder >
6 </ Fieldset >
7 </ Layouttemplate >
8 < Itemseparatortemplate >
9 < HR />
10 </ Itemseparatortemplate >
11 < Itemtemplate >
12 < Div ID = " Item " >
13 < H6 > Product Name: <% # Eval ( " Productname " ) %> (Product Classification code: <% # Eval ( " Categoryid " ) %> ) </ H6 >
14 Product unit price: <% # Eval ( " Unitprice " , " {0: c} " ) %>
15 Unit quantity: <% # Eval ( " Quantityperunit " ) %>
16 </ Div >
17 </ Itemtemplate >
18 </ ASP: listview >

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.