asp+| Control DATAGRID3
DATAGRID3 is built on DataGrid2 by adding visual formatting and content formatting.
Excerpt from datagrid3.aspx:
〈%@ Page language= "C #" src= "DataGrid.cs" inherits= "Samples.data
Gridpage "%〉
...
〈asp:datagrid runat=server id= "Titlesgrid"
Autogeneratecolumns= "false"
Width= "80%"
Backcolor= "White"
Borderwidth= "1px" borderstyle= "Solid" cellpadding= "2" Cell
spacing= "0"
Bordercolor= "Tan"
Font-name= "Song Body" font-size= "8pt"
〈property name= "Columns"
〈asp:boundcolumn headertext= "title" datafield= "title"/〉
〈asp:boundcolumn headertext= "Author" datafield= "Au_name"/〉
〈asp:boundcolumn headertext= "Date published" Datafield=
"Pubdate"
dataformatstring= "{0:mmm yyyy}"/〉
〈asp:boundcolumn headertext= "Price" datafield= "Price"
Dataformatstring= "{0:c}"
〈property name= "ItemStyle"
〈asp:tableitemstyle horizontalalign= "right"/〉
〈/property〉
〈/asp:boundcolumn〉
〈/property〉
〈property name= "HeaderStyle"
〈asp:tableitemstyle backcolor= "darkred" forecolor= "white"
Font-bold= "true"/〉
〈/property〉
〈property name= "ItemStyle"
〈asp:tableitemstyle forecolor= "Darkslateblue"/〉
〈/property〉
〈property name= "AlternatingItemStyle"
〈asp:tableitemstyle backcolor= "Beige"/〉
〈/property〉
〈/asp:datagrid〉
this. aspx file displays the same DataGrid control declaration as before and sets various
Style properties. This will result in a more visually appealing representation. There is still no need to allow code to be
Change, using the same code-supported file as the previous example.
Because it is obtained from WebControl, the DataGrid control inherits such
style attributes such as Width, BackColor, BorderStyle, and Font.Name. Furthermore
The DataGrid provides properties such as cellpadding, which are specific to the table. This
Some properties allow you to customize the control in general.
The declaration also shows several item styles that are set, such as HeaderStyle and alternating
ItemStyle. These styles control the appearance of their corresponding items. Note that this example appears in the
Style merge. Alternative items have the same foreground color as general items, because their styles are
Combination of AlternatingItemStyle and ItemStyle. Finally, the example is also aligned with the right
The text in the Price column indicates that the style is set for a particular column.
The DataGrid also allows you to format text content in its cells. This is done by setting the bound
The DataFormatString property value of column is completed. The column uses its format description to format the
The contents of the cell with String.Format. This property can be formatted with the format type (such as date or currency)
To preset or append any content together. In addition, because formatting takes into account the CultureInfo of the current page
and requests, so it also supports global. If no format is specified, the ToString of the value is used
Method.
DataGrid4
DataGrid4 describes how to use the SelectedIndexChanged event to handle the
The selection in the DataGrid.
Truncated from datagrid4.aspx:
〈%@ Page language= "C #" src= "DataGrid4.cs" inherits= "Samples.
Datagrid4page "%〉
...
〈asp:datagrid runat=server id= "Titlesgrid"
Autogeneratecolumns= "false"
Width= "80%"
Backcolor= "White"
Borderwidth= "1px" borderstyle= "Solid" cellpadding= "2"
cellspacing= "0"
Bordercolor= "Tan"
Font-name= "Song Body" font-size= "8pt"
Datakeyfield= "title_id"
Onselectedindexchanged= "Onselectedindexchangedtitlesgrid"
〈property name= "Columns"
〈asp:buttoncolumn text= "Select" command= "select"/〉
〈asp:boundcolumn headertext= "title" datafield= "title"/〉
〈asp:boundcolumn headertext= "Author" datafield= "Au_name"/〉
〈asp:boundcolumn headertext= "Date published" Datafield=
"Pubdate"
dataformatstring= "{0:mmm yyyy}"/〉
〈asp:boundcolumn headertext= "Price" datafield= "Price"
Dataformatstring= "{0:c}"
〈property name= "ItemStyle"
〈asp:tableitemstyle horizontalalign= "right"/〉
〈/property〉
〈/asp:boundcolumn〉
〈/property〉
〈property name= "HeaderStyle"
〈asp:tableitemstyle backcolor= "darkred" forecolor= "white"
Font-bold= "true"/〉
〈/property〉
〈property name= "ItemStyle"
〈asp:tableitemstyle forecolor= "Darkslateblue"/〉
〈/property〉
〈property name= "AlternatingItemStyle"
〈asp:tableitemstyle backcolor= "Beige"/〉
〈/property〉
〈proper