Asp.net Details View control



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
AllowPagingtrue/false. Indicate whether the control should support navigation.
DataSourceGets or sets the data source object that contains the data to populate the control.
DataSourceIDIndicate the bound data source control to use (Generally used when we are using SqlDataSource or AccessDataSource to bind the data, See 1st Grid example).
AutoGenerateEditButtontrue/false. Indicates whether a separate column with edit link/button should be added to edit the record.
AutoGenerateDeleteButtontrue/false. Indicates whether a separate column with delete link/button should be added to delete the record.
AutoGenerateRowstrue/false. Indicate whether rows are automatically created for each field of the data source. The default is true.
DefaultModeread-only/insert/edit. Indicate the default display mode.
Style Properties of the DetailsView Control
AlternatingRowStyleDefines the style properties for every alternate row in the DetailsView.
EditRowStyleDefines the style properties for the row in EditView (When you click Edit button for a row, the row will appear in this style).
RowStyleDefines the style properties of the rows of the DetailsView.
PagerStyleDefines the style properties of Pager of the DetailsView. (If AllowPaging=true, the page number row appears in this style)
EmptyDataRowStyleDefines the style properties of the empty row, which appears if there is no records in the data source.
HeaderStyleDefines the style properties of the header of the DetailsView. (The column header appears in this style.)
FooterStyleDefines the style properties of the footer of DetailsView.
Appearance Properties of the DetailsView Control
CellPaddingIndicates the amount of space in pixel between the cells and the border of the DetailsView.
CellSpacingIndicates the amount of space in pixel between cells.
GridLinesBoth/Horizontal/Vertical/None. Indicates whether GrdiLines should appear or not, if yes Horizontal, Vertical or Both.
HorizontalAlignIndicates the horizontal alignment of the DetailsView.
EmptyDataTextIndicates the text to appear when there is no record in the data source.
BackImageUrlIndicates the location of the image that should display as a background of the DetailsView.
CaptionGets or sets the caption of the DetailsView.
CaptionAlignleft/center/right. Gets or sets the horizontal position of the DetailsView caption.
State Properties of DetailsView Control
RowsGets the collection of objects that represent the rows in the DetailsView.
FooterRowReturns a DetailsViewRow object that represents the footer of the DetailsView.
HeaderRowReturns a DetailsViewRow object that represents the header of the DetailsView.
PageCountGets the number of the pages required to display the records of the data source.
PageIndexGets or sets the 0-based page index.
DataKeyNamesGets an array that contains the names of the primary key field of the currently displayed rows in the DetailsViewRow.
DataKeysGets 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
ItemCommandFires when any clickable element on the control is clicked.
ItemCreatedFires after DetailsView fully creates all rows of the record.
ItemDeleting, ItemDeletedBoth event fires when current record is deleted. The first one fires before and other fires after record is deleted.
ItemInserting, ItemInsertedBoth event fires when an item is inserted. The first one fires before and second after the item is created.
ItemUpdating, ItemUpdatedBoth event fires when an item is updated. The first one fires before and second fires after the record is updated.
ModeChanging, ModeChangedBoth event fires when DetailsView change its display mode. The first one fires before and second fires after display mode is changed.
PageIndexChanging, PageIndexChangedBoth event fires when the DetailsView move to another record. The first one fires before and second fires after page is changed.




AutoID17304
Name787878
Address7878
Phone7878
City787878
Edit Delete New
12345678

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>


Share on Google Plus

About It E Research

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment