Description View Control is a data-bound control that provides a single record at a time.
Description View Control is a data-bound control that provides a single record at a time. It can also provide navigation options, can also insert, update, and delete this record. When sung on the page, it is usually implemented through the <table> HTML tag.
Its properties such as backcolor, foreclosure, border collar, border style, borderwidth, height etc are implemented through the style of the <table> tag.
Behavior Properties of the DetailsView Control | |
---|---|
AllowPaging | true/false. Indicate whether the control should support navigation. |
DataSource | Gets or sets the data source object that contains the data to populate the control. |
DataSourceID | Indicate the bound data source control to use (Generally used when we are using SqlDataSource or AccessDataSource to bind the data, See 1st Grid example). |
AutoGenerateEditButton | true/false. Indicates whether a separate column with edit link/button should be added to edit the record. |
AutoGenerateDeleteButton | true/false. Indicates whether a separate column with delete link/button should be added to delete the record. |
AutoGenerateRows | true/false. Indicate whether rows are automatically created for each field of the data source. The default is true. |
DefaultMode | read-only/insert/edit. Indicate the default display mode. |
Style Properties of the DetailsView Control | |
AlternatingRowStyle | Defines the style properties for every alternate row in the DetailsView. |
EditRowStyle | Defines the style properties for the row in EditView (When you click Edit button for a row, the row will appear in this style). |
RowStyle | Defines the style properties of the rows of the DetailsView. |
PagerStyle | Defines the style properties of Pager of the DetailsView. (If AllowPaging=true, the page number row appears in this style) |
EmptyDataRowStyle | Defines the style properties of the empty row, which appears if there is no records in the data source. |
HeaderStyle | Defines the style properties of the header of the DetailsView. (The column header appears in this style.) |
FooterStyle | Defines the style properties of the footer of DetailsView. |
Appearance Properties of the DetailsView Control | |
CellPadding | Indicates the amount of space in pixel between the cells and the border of the DetailsView. |
CellSpacing | Indicates the amount of space in pixel between cells. |
GridLines | Both/Horizontal/Vertical/None. Indicates whether GrdiLines should appear or not, if yes Horizontal, Vertical or Both. |
HorizontalAlign | Indicates the horizontal alignment of the DetailsView. |
EmptyDataText | Indicates the text to appear when there is no record in the data source. |
BackImageUrl | Indicates the location of the image that should display as a background of the DetailsView. |
Caption | Gets or sets the caption of the DetailsView. |
CaptionAlign | left/center/right. Gets or sets the horizontal position of the DetailsView caption. |
State Properties of DetailsView Control | |
Rows | Gets the collection of objects that represent the rows in the DetailsView. |
FooterRow | Returns a DetailsViewRow object that represents the footer of the DetailsView. |
HeaderRow | Returns a DetailsViewRow object that represents the header of the DetailsView. |
PageCount | Gets the number of the pages required to display the records of the data source. |
PageIndex | Gets or sets the 0-based page index. |
DataKeyNames | Gets an array that contains the names of the primary key field of the currently displayed rows in the DetailsViewRow. |
DataKeys | Gets a collection of DataKey objects that represent the value of the primary key fields set in DataKeyNames property of the DetailsViewRow. |
Events of the DetailsView Control | |
ItemCommand | Fires when any clickable element on the control is clicked. |
ItemCreated | Fires after DetailsView fully creates all rows of the record. |
ItemDeleting, ItemDeleted | Both event fires when current record is deleted. The first one fires before and other fires after record is deleted. |
ItemInserting, ItemInserted | Both event fires when an item is inserted. The first one fires before and second after the item is created. |
ItemUpdating, ItemUpdated | Both event fires when an item is updated. The first one fires before and second fires after the record is updated. |
ModeChanging, ModeChanged | Both event fires when DetailsView change its display mode. The first one fires before and second fires after display mode is changed. |
PageIndexChanging, PageIndexChanged | Both event fires when the DetailsView move to another record. The first one fires before and second fires after page is changed. |
|
Example -
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="DetailsView (Declarative).aspx.vb"Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DetailsView
id="dtlProducts"
DataSourceID="SqlDataSource1"
Runat="server" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:DatabaseConnectionString1.ProviderName %>"
SelectCommand="SELECT [ID], [TITLE], [COMPANY], [PRICE], [AVAILABLITY] FROM [PRO_LIST]">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
0 comments:
Post a Comment