DetailsView Class
<Description>
Displays the values of a single record from a data source in a table, where each data row represents a field of the record. The DetailsView control allows you to edit, delete, and insert record
<Properties>
AllowPaging: gets or sets a value indicating whether the paging feature is enabled
AutoGenerateRows : gets or sets a value indicating whether row fields for each field in the data source are automatically generated and displayed in a DetailsView control.
Caption: gets or sets the text to render in an HTML caption element in a DetailsView control.
DataSource: gets or sets the object from which the data-bound control retrieves its list of data items
HeaderRow: gets a DetailsViewRow object that represents the header row in a DetailsView control
Page:
PageCount:
<Method>
CreateFieldSet
CreateRow
CreateTable:
DataBind:
OnPreRender:
OnUnload:
Render:
SaveControlState:
SaveViewState:
UpdateItem: updates the current record in the data source
<Events>
DataBinding:
Init:
ItemCommand:
ItemUpdated:
ItemInserted:
ItemDeleted:
<Example>
The following code example demonstrates how to use a DetailsView control in combination with a GridView control for a simple master-detail scenario.
<table>
<tr>
<td>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
DataSourceID="Customers"
DataKeyNames="CustomerID">
<Columns>
<asp:CommandField ShowSelectButton="true" />
<asp:BoundField DataField="ContactName" HeaderText="ContactName" />
<asp:BoundField DataField="CompanyName" HeaderText="CompanyName" />
</Columns>
</asp:GridView>
</td>
<td valign="top">
<asp:DetailsView ID="DetailsView1" runat="server"
AutoGenerateRows="true" DataKeyNames="CustomerID"
DataSourceID="Details" Height="50px" Width="301px">
</asp:DetailsView>
</td>
</tr>
</table>
<asp:SqlDataSource ID="Details" runat="server"
ConnectionString="<%$ ConnectionStrings:MOConnectionString %>"
SelectCommand ="select * from tblMOTest where CustomerID = @CustomerID">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="CustomerID"
PropertyName="SelectedValue"
type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="Customers" runat="server"
ConnectionString="<%$ ConnectionStrings:MOConnectionString %>"
SelectCommand ="select CompanyName, ContactName, CustomerID from tblMOTest ">
</asp:SqlDataSource>
select CompanyName, ContactName, CustomerID from Customers
select * from Customers where CustomerID = @CustomerID
<Example2>
No comments:
Post a Comment